Link to home
Start Free TrialLog in
Avatar of neymeyer
neymeyer

asked on

easy...dialogs

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.
Avatar of WxW
WxW

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 .

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.
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.
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);  

 }
}

Avatar of neymeyer

ASKER

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.
ASKER CERTIFIED SOLUTION
Avatar of ScottyDawg
ScottyDawg

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Just what I was looking for.  I had everything except the GetParent() thing.  Thanks!