Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

easy...dialogs

Posted on 2000-02-14
7
Medium Priority
?
243 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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 200 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses

885 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