Destination
While elaborating on user's interface, we encounter with the issue of Dialog Content Window Changing while choosing any element of administration (Combo Box).
This article reproduces the method of realization of given chance.
Instruction
At first you are to create the parent window, the content of which will change, and place in it the element of administration managing the change. Let the falling list (ComboBox) control the change of the content of parent window. The child windows will be placed to the area framed by the rectangle control element - Picture
, Type - Frame
).
Now it's high time to create the child window - dialog window with the characteristics of Style
- Child
, Border
- None
and corresponding sizes. To create the child class for each dialog, children from CDialog
.
CDialogDlg
- parent's windows (Dialog based application);
CChildDlg1
- the first child's windows;
CChildDlg2
- the second child's windows.
Add to DialogDlg.h:
#include "ChildDlg1.h";
#include "ChildDlg2.h";
Add to determining the CDialogDlg
class:
public:
CChildDlg1 m_View1;
CChildDlg2 m_View2;
Then, add to the CDialogDlg::OnInitDialog()
function, before return TRUE
, the following text:
CWnd* pWnd = GetDlgItem( IDC_FRAME );
CRect rect;
pWnd->GetWindowRect( &rect );
ScreenToClient( &rect );
m_View1.Create( IDD_VIEW1, this );
m_View1.ShowWindow( WS_VISIBLE | WS_CHILD );
m_View1.SetWindowPos( pWnd, 0, rect.top, rect.right,
rect.bottom, SWP_SHOWWINDOW );
m_View2.Create( IDD_VIEW2, this );
m_View2.ShowWindow( WS_VISIBLE | WS_CHILD );
m_View2.SetWindowPos( pWnd, 0, rect.top, rect.right,
rect.bottom, SWP_HIDEWINDOW );
m_Select.SetCurSel(0);
To create function of the falling list (ComboBox), the content of which will change:
if (m_Select.GetCurSel() == 0)
{
m_View1.ShowWindow(SW_SHOW);
m_View2.ShowWindow(SW_HIDE);
}
else
{
m_View1.ShowWindow(SW_HIDE);
m_View2.ShowWindow(SW_SHOW);
}
It's compiling and running.