Solved

Creating a child dialog

Posted on 1998-12-31
5
177 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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 is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.

932 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

12 Experts available now in Live!

Get 1:1 Help Now