Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

1. Start Microsoft Visual C++ .NET or MS Visual Studio .NET 2. Create a new MFC Application named Primary1 3.

Create it as Dialog Based

4. Set the Dialog Title to Calling One Dialog Box From Another

5. Click Finish 6. To add another dialog box, on the main menu, click Project -> Add Resource... 7. In the Add Resource dialog box, double-click Dialog 8. Change the ID of the new dialog to IDD_SECOND_DLG and its Caption to Second 9. Right-click the dialog box and click Add Class... 10. Set the Class Name to CSecondDlg and base it on CDialog 11. Click Finish 12. From the Class View, double-click the IDD_PRIMARY1_DIALOG 13. Using the Toolbox, add a Button to the dialog box and change its properties as follows: Caption: Second ID: IDC_SECOND_BTN 14. Double-click the new Second button and implement its event as follows: // Primary1Dlg.cpp : implementation file // #include "stdafx.h" #include "Primary1.h"

#include "Primary1Dlg.h" #include ".\primary1dlg.h" #include "SecondDlg.h" #ifdef _DEBUG #define new DEBUG_NEW #endif // CPrimary1Dlg dialog . . . No Change // The system calls this function to obtain // the cursor to display while the user drags // the minimized window. HCURSOR CPrimary1Dlg::OnQueryDragIcon() { return static_cast<HCURSOR>(m_hIcon); } void CPrimary1Dlg::OnBnClickedSecondBtn() { // TODO: Add your control notification handler code here CSecondDlg Dlg; Dlg.DoModal(); } 15. Test the application

You might also like