[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Opening another dialog (closing original)

Posted on 1998-11-20
6
Medium Priority
?
192 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
Independent Software Vendors: 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

Technology Partners: 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!

Question has a verified solution.

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

Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

650 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