?
Solved

Creating a child dialog

Posted on 1998-12-31
5
Medium Priority
?
187 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 150 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

850 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