Solved

Opening another dialog (closing original)

Posted on 1998-11-20
6
177 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 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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
Strange date stored 22 174
Turn a spreadsheet into a vba executable. 2 98
Window placement 17 95
Dell Alienware Graphics Amplifier Driver for non-Alienware systems 18 475
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 …
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

733 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