Communication with different dialogue box in same MFC dialogue based application

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:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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:
1
2
3
4
5
6
7
void CCheckout_Code::OnBnClickedBack()
{
	// TODO: Add your control notification handler code here
	UpdateData(TRUE);
	CPrevApp startDlg;
		startDlg.DoModal();
}
I presume you are using MFC. Say that your main dialog has a class named CMainDlg. You will see in your code that has been generated for you (assuming you initially created your MFC project via the new project wizard), an ::InitInstance() in the main project class in there you will see that an instance of your class CMainDlg has been created on the stack and DoModal() will have been called, this is so that your main dialog is displayed when your start the app'. If you wish to add some additional dialogs that are displayed prior to the main dialog then add their respective clasees etc, create an instance of them before the DoModal() is called on the main dialog and call DoModal() on them first.

Does that help?
where i have to call these new dialogues objects?in Initinstance or OnInitdialogue of main application?
Last edited on
Please try and explain what you are trying to do then. YOu have a main dialog and two other dialogs. Reply with a numbered list that shows what you intend your app to do, i.e.

1) Instantiate CSubDlg instance
2) Show CSubDlg window
3) User dissmisses CSubDlg window
4) Instantiate CFurtherSubDlg instance
5) Show CFurtherSubDlg window
6) User dissmisses CFurtherSubDlg window
7) Instantiate CMainDlg instance
8) Show CMainDlg window
...
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
Last edited on
When you say "automatic dissmisses..." in (3) and (6) above, what do you mean? Is the dialog to close on a timer event?
Sorry! Not automatic dismissed but hidden or invisible like that; as normally happened in any windows application installation(visual studio) which display back and next button like that.

I think you need to reconsider your design. For a CDialog based application you must always have a CWnd object being the main apps window which is around for the life of the application instance. This would appear to be the CSubDlg instance, which when sent the message ShowWindows(SW_HIDE) is no longer on view and the CFurtherSubDlg windows is the displayed via DoModal() ?? which in turn either shows the CSubDlg or the CMainDlg. I don't know.

If you were to describe what you were attempting to do it might be helpful. The class names I have so far used were only to differentiate between the different dialog classes and would be better if they were suitably named along the lines of their purpose
Topic archived. No new replies allowed.