Solved

Creating a child dialog

Posted on 1998-12-31
5
179 Views
Last Modified: 2013-11-20
I have a program that is a dialog based only (VC 6.0 ).  I would like to make load two different dialogs at different times( by selecting it from a menu selection ).  But the dialog should be a child to the main windows so if i maximize the dialog all the controls are still under the main window like word were maximizing the child screen is still under the main window.  I dont really know how to load that type of dialog by selecting from a menu or if the dialog I create should have a base class of CDialog or something else.  Is there a good mfc example on how to do this?  But more important how to load the dialog by selecting a menu control.

Thanks
0
Comment
Question by:eric07
  • 3
  • 2
5 Comments
 
LVL 6

Accepted Solution

by:
thresher_shark earned 50 total points
ID: 1327103
Long winded answer coming...
0
 
LVL 6

Expert Comment

by:thresher_shark
ID: 1327104
You mention you want to prevent the dialog from getting larger than its parent.  This is possible, but probably not worth the effort.  I recommend you disable the maximize button as a maximized dialog box will almost always look very bad.  You can disable the maximize button by right clicking the dialog, selecting properties, and then unchecking the Maximize button option under the "Styles" tab.

Here is what you want to do:
1) If you haven't already, "attach" the menu to the dialog you want it to appear in.  You can do this by creating the menu resource, and then going to classwizard.  It will ask you if you want to "create a new class" or "select an existing class."  Use the "select and existing class" option.  Then, when it prompts you for a class, select the dialog box class that you want it to be associated with.

2) Add the item to the menu that you want to have clicked and assign it a resource ID.  For the purposes of the explanation, name it ID_CLICKTHIS.

3) Go back into classwizard, and select the ID_CLICKTHIS resource on the left side of the screen.  Then, assign a "COMMAND" handler to it by double clicking "COMMAND" on the right side of the screen.

4) Select OK in the dialog box that appears.

5) Click the edit code button.

6) You are now brought to the source code.  Delete the "TODO:" comment.  Now, add
  CTheDialogYouWantToAppear dlg;
  dlg.DoModal ();
   to the function.  This will cause a new dialog box to be displayed.  The CTheDialogYouWantToAppear is the dialog class that you have associated with your dialog resource (whatever it may be).  Make sure you include the correct header (.H) file for this, otherwise it will give you errors when you compile the program,

7) Recompile and run the program.  It should work now.

If you have additional questions, please feel free to ask.  Thanks!
0
 

Author Comment

by:eric07
ID: 1327105
I guess my question is how to load a dialog I created as a MDIchild.
0
 

Author Comment

by:eric07
ID: 1327106
I guess my question is how to load a dialog I created as a MDIchild.
0
 
LVL 6

Expert Comment

by:thresher_shark
ID: 1327107
Oh... That's a completely different question.  You shouldn't have "accepted" my answer until it suited your needs.  I am not sure how to answer that one either :-(
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
conditional code and condition difference 9 85
FizzBuzz challenge 9 86
matchUp  challenge 9 126
sumHeights2  challenge 7 132
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question