Click here to Skip to main content
15,892,537 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I already designed one dialogue based application in MFC and I want to add two dialogues before the main dialogue open.I tried to call one of the new dialogue through OnInitDialogue() function and I do that using DoModal() method in old application,but my condition is that old main dialogue should be opened as some variable conditions and not opened with pressing escape button or closing new dialogue!
and another query is: I used Back button on old dialogue which should display previous dialogue! How to do that?
I copy some code from my application below:
C++
CDialog::OnInitDialog();
	

	// Add "About..." menu item to system menu.

	// IDM_ABOUTBOX must be in the system command range.
	ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
	ASSERT(IDM_ABOUTBOX < 0xF000);

	CMenu* pSysMenu = GetSystemMenu(FALSE);
	if (pSysMenu != NULL)
	{
		CString strAboutMenu;
		strAboutMenu.LoadString(IDS_ABOUTBOX);
		if (!strAboutMenu.IsEmpty())
		{
			pSysMenu->AppendMenu(MF_SEPARATOR);
			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
		}
	}

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon

	// TODO: Add extra initialization here
	UpdateData(TRUE);
	CMainApp dlg;
	dlg.DoModal();

and code below explains how I called new dialogue on clicked event of Back button of old dialogue:
C++
void CCheckout_Code::OnBnClickedBack()
{
	// TODO: Add your control notification handler code here
	UpdateData(TRUE);
	CPrevApp startDlg;
		startDlg.DoModal();
}
Posted
Updated 16-Jul-13 23:42pm
v2
Comments
Venkat Raghvan 17-Jul-13 6:28am    
I have three dialogues and I will numbering what is happened in my application
I have a main dialog and two other dialogs.
1) Instantiate CSubDlg instance
2) Show CSubDlg window
3) Automatic dissmisses CSubDlg window
4) Instantiate CFurtherSubDlg instance which contain Back button and Run Button
5)If user clicks on Back button should open CSubDlg
6)If user clicks Run button it should open CMainDlg window and automatic dismisses CFurtherSubDlg
7) CMainDlg also contain Back button.
8)On Click Back button CFurtherSubDlg should show

1 solution

Since CCheckout_Code and CPrevApp are both your code, you can simply add a pointer in the class of interest pointing to the 'other' class. If you have 2 dialogs that need to point to each other, you could cache a pointer to each in the parent or owning class and ask the parent/owner for the pointer to the 'other' class as needed.

If you have dialogs where you want to go back and forth between them, you probably want to look at Property Page and Property Sheet paradigms. Clickety[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900