Click here to Skip to main content
Licence 
First Posted 29 Feb 2004
Views 66,188
Bookmarked 15 times

A Simple Way for Changing the Content of the Dialog

By | 29 Feb 2004 | Article
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

About the Author

algusen@yandex.ru

Web Developer

Russian Federation Russian Federation

Member



Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralI am curious... PinmemberSam Levy5:09 1 Mar '04  
GeneralRe: I am curious... PinmemberMaximilien5:57 1 Mar '04  
GeneralRe: Curious - This rocks Pinmemberconrad Braam18:36 1 Mar '04  
GeneralVerbosity with not much else. PinmemberWREY4:56 1 Mar '04  
GeneralRe: Verbosity with little else to support it. PinmemberHarold Bamford5:14 1 Mar '04  
GeneralRe: Verbosity with little else to support it. PinmemberWREY5:37 1 Mar '04  
GeneralRe: Verbosity with little else to support it. PinmemberHarold Bamford5:54 1 Mar '04  
GeneralRe: Verbosity with little else to support it. PinmemberPaul Belikian5:16 1 Mar '04  
GeneralRe: Verbosity with not much else. Pinsussalgusen9:34 1 Mar '04  
GeneralRe: Verbosity with not much else. Pinmemberpeterchen9:39 1 Mar '04  
GeneralRe: Verbosity with not much else. PinmemberWREY11:05 2 Mar '04  
GeneralRe: Verbosity with not much else. Pinmemberpeterchen12:13 2 Mar '04  
GeneralRe: Verbosity with not much else. PinmemberWREY9:50 3 Mar '04  
GeneralRe: Verbosity with not much else. Pinmemberpeterchen11:04 3 Mar '04  
GeneralRe: Verbosity with not much else. PinmemberWREY10:47 4 Mar '04  
GeneralRe: Verbosity with not much else. Pinmemberpeterchen22:41 4 Mar '04  
GeneralRe: Verbosity with not much else. PinmemberWREY3:13 5 Mar '04  
GeneralRe: Verbosity with not much else. Pinmembersnakeware11:52 1 Mar '04  
GeneralRe: Verbosity with not much else. PinmemberWREY9:59 2 Mar '04  
GeneralRe: Verbosity with not much else. Pinmemberxenium0418:03 18 May '04  
GeneralRe: Verbosity with not much else. PinmemberWREY0:13 19 May '04  
GeneralRe: Verbosity with not much else. PinmemberFlying Spaghetti Monster3:40 25 Feb '10  
GeneralRe: Verbosity with not much else. PinmemberWREY19:31 25 Feb '10  
Generalfatal error RC1015: cannot open include file 'l.rus\afxres.rc'. Pinmembergeorge ivanov3:37 1 Mar '04  
GeneralRe: fatal error RC1015: cannot open include file 'l.rus\afxres.rc'. Pinmemberalgusen@yandex.ru9:17 1 Mar '04  

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

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

Permalink | Advertise | Privacy | Mobile
Web02 | 2.5.120517.1 | Last Updated 1 Mar 2004
Article Copyright 2004 by algusen@yandex.ru
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid