Re: Linking diaglog windows to buttons
On 18 May 2007 07:22:11 -0700, Katie Turfkruyer
<katieturfy@googlemail.com> wrote:
Can anyone please assist with my problem ... I am new to visual C++
and am stuck at what I hope is a relatively straight forward
problem...
I'm creating a dialog based application in Visual C++ 6.0.
I'm finding it impossible to link dialog window buttons to other
dialog windows, e.g. I want: if I click button 1 on window 1 and for
window 2 to appear, if I click button 2 on window 1 and window 3
appears.
I don't know if I correctly understand your problem...
However, for every dialog-box (I think that "dialog window" ==
dialog-box, right?) in your app, you have a class derived from
CDialog.
So you can have: CDialog1, CDialog2, CDialog3 classes (all derived
from CDialog base class). CDialog1 is associated to your dialog 1,
CDialog2 to your dialog 2, etc.
In your dialog #1 you have the button 1, and you have a member
function which is called by MFC when the user clicks button 1, e.g.
CDialog1::OnButton1Clicked, right?
So, you want to show dialog #2 when the user clicks button 1 on dialog
#1, right?
Well, in the body of the CDialog1::OnButton1Clicked() method, you just
create an instance of dialog #2 class (CDialog2, in our example), and
call DoModal() method to show the dialog 2:
// In Dialog1.cpp
#include "Dialog2.h" // We need CDialog2 class
...
...
// When user presses button 1 on dialog 1 ...
void CDialog1::OnButton1Clicked()
{
// ... Show dialog 2
CDialog2 dialog2;
dialog2.DoModal();
}
I'm sorry if I misunderstood your original question...
MrAsm