?
Solved

Creating a child dialog

Posted on 1998-12-31
5
Medium Priority
?
181 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

Question has a verified solution.

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

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…
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.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Suggested Courses
Course of the Month10 days, 10 hours left to enroll

764 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