Solved

easy...dialogs

Posted on 2000-02-14
7
203 Views
Last Modified: 2012-05-04
I want to be able to have a button that loads a new dialog and hides the current.  I also want to have a button on the second dialog which will unload itself and load the first dialog again.  Does this make sense?  I am new to VC++ and could use as much code as possible.  Leave a comment if you need clarification on any of this.
0
Comment
Question by:neymeyer
7 Comments
 
LVL 6

Expert Comment

by:WxW
ID: 2520400
So is that difficult ?

The WM_COMMAND handler for each window should do
1st DestroyWindow(CurrentDialog)
2nd CreateDialog(prgInstance,"DIALOG_OTHER",0,DialogProc);

3rd If you don't know the Windows API and/or you use a VC++ class , you need either a VC++ expert ( and I am not ! ) , or use the above code modified in your message handler .

0
 
LVL 1

Expert Comment

by:jwilcox
ID: 2520524
Since you want to keep the first dialog alive, you could probably also just set the first dialog as hidden I haven't worked in VC++ in about 2-3 months but I believe its dialog.visible(FALSE);

That shouldn't cause problems, even if they are modal dialog boxes, but I could be wrong.
0
 

Expert Comment

by:malamontagne
ID: 2521101
You simply have to create the second windows with the Create function when the user click on your button and then call ShowWindow() on the first window with the hide option. After that, when the user click the button on the second window, you hide this window the same way as the first one and the call ShowWindow() with the Show option.

Naturally, you will need to pass the handler of the windows to each other to have the access that you need.
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 5

Expert Comment

by:Wyn
ID: 2521108
Add a button to the first.

void CDialog1::OnButton()
{
 CDialog2 dlg2;
 ShowWindow(SW_HIDE);  
 if (dlg2.DoModal()==IDOK)
 {
   
//some things here,like
 ShowWindow(SW_SHOW);  

 }
}

0
 

Author Comment

by:neymeyer
ID: 2523078
Wyn,
I have this part done.  What I want to be able to do is re-call the first dialog from a button click on the second dialog.  The real problem is that I can't just call the first one the same way as the second because it is created with the CDialogDlg class that is automatically created with the MFC Wizard.  Malamontagne, I think you have the solution to my problem, but could you please include some code?  Thanks.
0
 
LVL 1

Accepted Solution

by:
ScottyDawg earned 50 total points
ID: 2523324
In 2nd dialog when your button is pushed call

GetParent()->ShowWindow(SW_SHOW);
EndDialoag(ID_OK);


this will work providing that you 2nd dialog was created something like

C2ndDialoag Dlg2(IID, this);

the "this" being the important bit...
0
 

Author Comment

by:neymeyer
ID: 2523386
Just what I was looking for.  I had everything except the GetParent() thing.  Thanks!
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…

705 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now