Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

easy...dialogs

Posted on 2000-02-14
7
Medium Priority
?
236 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
[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
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
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 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…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

670 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