Solved

Creating a child dialog

Posted on 1998-12-31
5
176 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
Comment Utility
Long winded answer coming...
0
 
LVL 6

Expert Comment

by:thresher_shark
Comment Utility
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
Comment Utility
I guess my question is how to load a dialog I created as a MDIchild.
0
 

Author Comment

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

Expert Comment

by:thresher_shark
Comment Utility
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
sumDigits challenge 9 95
modThree challenge 4 64
changeXy challenge 13 56
Change to event 1 72
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 …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
This video discusses moving either the default database or any database to a new volume.

762 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now