Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pressing a button invokes a window 1

Status
Not open for further replies.

Sedai

Programmer
Mar 4, 2001
158
US
I don't know much about Win32 programming, I've just started using MFC.
A newbie question: I've created a resource, a dialog box.
My app actually consists of one dialog box with a couple of buttons. When I click one of them, I need the other dialog box to appear. How does one do that?
Thanks. Avendeval


 
I'm pretty much a newbie too, but I happen to know this one :)

CMyDialog1::OnOK(){
CMyDialog2 theDlg;

theDlg.DoModal(); // Show here

CDialog::OnOK();
}

Hope that helps!

~Mike
Any man willing to sacrifice liberty for security deserves neither liberty nor security.

-Ben Franklin
 
1. Activate the ClassWizard, ctrl-W.

2. Select "Message Maps" tab

3. Make sure the "Class name:" dropdown list box is you dialog class name. For example CMyDialog

4. In the "Object IDs" list box, select the ID of your button. Say IDC_BUTTON1

5. In the "Messages:" list box, select "BN_CLICKED".

6. Click on "Add Function" button

7. An "Add Member Function" dialog box appear and offer a default member function name. For this example: OnButton1. Click OK to select this default value and close this dialog. We are now back to MFC ClassWizard dialog.

8. Click EditCode to closs the ClassWizard dialog and bring you to the CMyDialog::OnButton1() member function.

9. You can now active your second dialog in response to the OnButton1() button. For example:
void CMyDialog::OnButton1()
{
CMyDialog2 dlg;
dlg.DoModel();
}

HTH
Shyan

 
thanks Shyan, I already got help from Mike. Thanks though!! Avendeval


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top