Solved

Opening another dialog (closing original)

Posted on 1998-11-20
6
175 Views
Last Modified: 2013-11-20
I would like my dialog-based program to open on the default dialog (IDD_DIALOG1) and then, through a function that's called when a selection is made from a menu, call/open another dialog (in the same project) called IDD_DIALOG2.  If possible I would like for the original dialog window to close at this time.  I'm a beginner so I don't know how complicated or simple this may be.  I'd appreciate any help you can provide.  Thanks a lot.
0
Comment
Question by:jkeebler
  • 3
  • 2
6 Comments
 
LVL 3

Accepted Solution

by:
plaroche earned 70 total points
ID: 1325076
Let's say your command handler in the first dialog is:

OnShowDialog2()
{
     CDialog2  dlg;
     int       ret;

     ShowWindow(SW_HIDE);  // Hide this dialog
     ret = dlg.DoModal();  // Show the 2nd dialog
     ShowWindow(SW_SHOW);  // Re-show the 1st dialog
}

One thing is for sure; to keep it simple your first dialog must not close with OnOK or OnCancel because in a simple dialog application this will terminate the application. Now it would only hide itself and show the 2nd dialog. When the 2nd dialog will return from DoModal, ie when it's closed, your 1st dialog will show up.
if you don't want the 1st to re-show then replace ShowWindow(SW_SHOW) by OnOK();

0
 

Author Comment

by:jkeebler
ID: 1325077
Thanks a lot for your quick response to my question :-)  I'll tell your what I did.

I made a new dialog called IDD_DIALOG1, made a new class called CDialog1, and made a button in the main dialog that, when clicked, calls a function containing your script:

         CDialog1 dlg;
         int ret;
         ShowWindow(SW_HIDE);
         ret = dlg.DoModal();
         ShowWindow(SW_SHOW);

When compiled, I got the following errors:

1) CDialog1: undecleared identifier
2) missing ; before identifier dlg
3) dlg: undecleared identifier
4) left of '.DoModal' must have class/struct/union type

Is there a quick step I can follow in ClassWizard to fix this?  A step to define CDialog1 in the main dialog?  Like I said, I'm new at Visual C++ programming and would appreciate any help you can give me.  Thanks again.

0
 
LVL 2

Expert Comment

by:wyy_cq
ID: 1325078
do you include header file?


0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:jkeebler
ID: 1325079
wyy_cq >> It was included automatically by ClassWizard (I'm pretty sure).  Do I have to make some sort of initializing statement to identify CDialog1 in the main dialog source?
0
 
LVL 3

Expert Comment

by:plaroche
ID: 1325080
The header file was not included by classwizrd. How could it know you want use that dialog in that cpp file.

You need to add an include directive to the top of the cpp file:

#include "dialog1.h"

where dialog1.h is the filename of the new dialog's header file.
0
 

Author Comment

by:jkeebler
ID: 1325081
That was the problem.  Thanks a lot.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Unix / Linux grid computing 5 163
format the code in java 6 101
Modbus - whats the maximum I can store in one register? 4 80
matchUp  challenge 9 115
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
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…
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 shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

832 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