Click here to Skip to main content
16,017,788 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 84K   808   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 
You are correct. My knowledge of Russian is about a dozen words, which lends itself exactly to the point behind my comment.

If I am going to write an article in Russian, knowing the total inadequacy of my ability to write any sensible statement in Russian, am I going to take on such a project by myself? COME ON!! It doesn't require a genius to know when something is beyond your capability.

OK, if my Russian is less than average, but enough to get my ideas across with some help and understanding from my audience, am I going to still consider that level of competence, sufficient to write an article in Russian, to a Russian audience? (HELLO!! Do you believe in living in fairyland?) Wouldn't you first come up with a rough draft of your article, and ask someone who knows the language better than you, to review it? Wouldn't you?

OK, let's say my knowledge of Russian is above average because I was living in that country for about a year, and picked up on the language fairly well (to the point where I know I can make sense in speaking and writing it). With that level of knowledge about the language, I wouldn't have a problem taking on the task of writing an article in Russian, to a Russian audience. Still, realizing my limitations, I know there will be many in the audience who will readily detect the many errors I would be committing, and immediately discern that I am NOT Russian.

My comment to the author, is where I detected him to be at the "below average" level, yet engaging in the language as if he were at the highest level of competency. That's the pretentiousness on which I based my comment.

At my "below average" knowledge of Russian, do you think if I don't know the words (or phrase) for "ComboBox," or "client area," or "drop down list" (etc.), I am going to write something like, "element of administration" or some other highfalutin phrase? COME ON!! Do you think I need to fake something?

Of the thousands upon thousands of CP members who struggle with their English to get their point across (or ask their questions), it's not difficult to see they are NOT faking anything. They are the genuine ones for whom English speaking persons (like myself) know there is NOTHING PRETENTIOUS about the words and phrases they use. You don't find them engaged in verbosity, using phrases like, "element of administration," and "the method of realization of given chance."

You darn well believe I would ask someone to review my Russian before publishing an article that uses those kind of phrases.

You are WRONG!! I wouldn't have to know Russian to understand where such phrases come from; I would simply have to know that my knowledge of the language is inadequate for me to use them.

To you I say, "Learn how to distinguish the tree from the forest."

Hmmm | :|

William

Fortes in fide et opere!
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 
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.