a question?
-
i create a popup dialog with mfc, and the dialog entered DoModal function, how can i close the dialog by pressing right-up close button and keep main-software keep going
-
i create a popup dialog with mfc, and the dialog entered DoModal function, how can i close the dialog by pressing right-up close button and keep main-software keep going
Handle the
WM_CLOSE
message and in the handler, hide the dialog instead of callingDestroyWindow
. This way the dialog is not shown anymore but the program is running.«_Superman_» I love work. It gives me something to do between weekends.
Microsoft MVP (Visual C++) -
i create a popup dialog with mfc, and the dialog entered DoModal function, how can i close the dialog by pressing right-up close button and keep main-software keep going
Since you said you called DoModal I assume you created a modal dialog box. When this dialog box is closed by clicking the top-right corner's close button, your application should still be running. You don't have to do anything to "keep it running". Clicking the close button should cause the DoModal to return the value IDCANCEL (and the dialog box being closed) unless you override the handler and do something else.
-
i create a popup dialog with mfc, and the dialog entered DoModal function, how can i close the dialog by pressing right-up close button and keep main-software keep going
-
Your main application should not stop running if you close a pop-up dialog box that it created. Unless there is some kind of crash happening on the pop-up dialog box clean up.
Suhredayan
-
Handle the
WM_CLOSE
message and in the handler, hide the dialog instead of callingDestroyWindow
. This way the dialog is not shown anymore but the program is running.«_Superman_» I love work. It gives me something to do between weekends.
Microsoft MVP (Visual C++) -
Since you said you called DoModal I assume you created a modal dialog box. When this dialog box is closed by clicking the top-right corner's close button, your application should still be running. You don't have to do anything to "keep it running". Clicking the close button should cause the DoModal to return the value IDCANCEL (and the dialog box being closed) unless you override the handler and do something else.
-
Try to overwirte the virtual function OnCancel(), and call EndDialog(n) in that. Or just call EndDialog(n) in OnClose() function.
-
Can you post the code part that is creating the pop up dialog. Just to see how you are creating this pop-up dialog within your application.
Suhredayan
OK My CApp: InitInstance() { ... static CDlg dlg; m_pMainWnd = &dlg; //int nResponse = dlg.DoModal(); //if (nResponse == IDOK) // ... // dlg.Init(); return TRUE; } i create win32 window in dlg.Init() and its CallBackWnd code segment : case WM_COMMAND: { if (IDD_CONTROL_PANEL == wParam) { ((CDlg*)AfxGetApp()->GetMainWnd())->DoModal(); } }
-
OK My CApp: InitInstance() { ... static CDlg dlg; m_pMainWnd = &dlg; //int nResponse = dlg.DoModal(); //if (nResponse == IDOK) // ... // dlg.Init(); return TRUE; } i create win32 window in dlg.Init() and its CallBackWnd code segment : case WM_COMMAND: { if (IDD_CONTROL_PANEL == wParam) { ((CDlg*)AfxGetApp()->GetMainWnd())->DoModal(); } }
This looks to me like a Dialog application, where the dialog is the main window. So when the dialog closes that is the end of the application. If you want a normal window application that uses dialogs then create a proper framewindow as the main window. If you are using Visual Studio then there are standard framewindow templates to build from.
-
i create a popup dialog with mfc, and the dialog entered DoModal function, how can i close the dialog by pressing right-up close button and keep main-software keep going