Click here to Skip to main content
15,885,008 members
Articles / Desktop Programming / MFC
Article

A Simple Way for Changing the Content of the Dialog

Rate me:
Please Sign up or sign in to vote.
2.89/5 (15 votes)
29 Feb 2004 83.4K   807   15   25
A simple way for changing the content of the dialog .

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 );

//Creating a ChildDld1
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 );

//Creating a ChildDld2
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); //Setting first element of a ComboBox

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.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
Russian Federation Russian Federation
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralI am curious... Pin
Sam Levy1-Mar-04 5:09
Sam Levy1-Mar-04 5:09 
GeneralRe: I am curious... Pin
Maximilien1-Mar-04 5:57
Maximilien1-Mar-04 5:57 
GeneralRe: Curious - This rocks Pin
conrad Braam1-Mar-04 18:36
conrad Braam1-Mar-04 18:36 
GeneralVerbosity with not much else. Pin
WREY1-Mar-04 4:56
WREY1-Mar-04 4:56 
GeneralRe: Verbosity with little else to support it. Pin
Harold Bamford1-Mar-04 5:14
Harold Bamford1-Mar-04 5:14 
GeneralRe: Verbosity with little else to support it. Pin
WREY1-Mar-04 5:37
WREY1-Mar-04 5:37 
GeneralRe: Verbosity with little else to support it. Pin
Harold Bamford1-Mar-04 5:54
Harold Bamford1-Mar-04 5:54 
GeneralRe: Verbosity with little else to support it. Pin
Paul Belikian1-Mar-04 5:16
Paul Belikian1-Mar-04 5:16 
GeneralRe: Verbosity with not much else. Pin
algusen@yandex.ru1-Mar-04 9:34
algusen@yandex.ru1-Mar-04 9:34 
GeneralRe: Verbosity with not much else. Pin
peterchen1-Mar-04 9:39
peterchen1-Mar-04 9:39 
GeneralRe: Verbosity with not much else. Pin
WREY2-Mar-04 11:05
WREY2-Mar-04 11:05 
GeneralRe: Verbosity with not much else. Pin
peterchen2-Mar-04 12:13
peterchen2-Mar-04 12:13 
GeneralRe: Verbosity with not much else. Pin
WREY3-Mar-04 9:50
WREY3-Mar-04 9:50 
GeneralRe: Verbosity with not much else. Pin
peterchen3-Mar-04 11:04
peterchen3-Mar-04 11:04 
GeneralRe: Verbosity with not much else. Pin
WREY4-Mar-04 10:47
WREY4-Mar-04 10:47 
GeneralRe: Verbosity with not much else. Pin
peterchen4-Mar-04 22:41
peterchen4-Mar-04 22:41 
GeneralRe: Verbosity with not much else. Pin
WREY5-Mar-04 3:13
WREY5-Mar-04 3:13 
GeneralRe: Verbosity with not much else. Pin
snakeware1-Mar-04 11:52
snakeware1-Mar-04 11:52 
You need to get a life.

Making an issue out of someone's use of
a language is about as cheap and petty
as it gets.


GeneralRe: Verbosity with not much else. Pin
WREY2-Mar-04 9:59
WREY2-Mar-04 9:59 
GeneralRe: Verbosity with not much else. Pin
xenium0418-May-04 18:03
xenium0418-May-04 18:03 
GeneralRe: Verbosity with not much else. Pin
WREY19-May-04 0:13
WREY19-May-04 0:13 
GeneralRe: Verbosity with not much else. Pin
Lekrot25-Feb-10 3:40
Lekrot25-Feb-10 3:40 
GeneralRe: Verbosity with not much else. Pin
WREY25-Feb-10 19:31
WREY25-Feb-10 19:31 
Generalfatal error RC1015: cannot open include file 'l.rus\afxres.rc'. Pin
george ivanov1-Mar-04 3:37
george ivanov1-Mar-04 3:37 
GeneralRe: fatal error RC1015: cannot open include file 'l.rus\afxres.rc'. Pin
algusen@yandex.ru1-Mar-04 9:17
algusen@yandex.ru1-Mar-04 9:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.