?
Solved

Opening another dialog (closing original)

Posted on 1998-11-20
6
Medium Priority
?
187 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
[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
6 Comments
 
LVL 3

Accepted Solution

by:
plaroche earned 280 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
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.

 

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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

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