How to avoid to close my App?
-
Hi guys I was wandering where I have to put this... ----------------------------------------------------------------------- int ret=AfxMessageBox("You will exit the program.\nContinue?",MB_YESNO); if (ret==IDNO) return ; (someone more is needed ?) ----------------------------------------------------------------------- ...in my SDI application when someone clicks on the right upper Cross (standard close button) of my app. Thanks in forwarding. Dr.Pi
-
Hi guys I was wandering where I have to put this... ----------------------------------------------------------------------- int ret=AfxMessageBox("You will exit the program.\nContinue?",MB_YESNO); if (ret==IDNO) return ; (someone more is needed ?) ----------------------------------------------------------------------- ...in my SDI application when someone clicks on the right upper Cross (standard close button) of my app. Thanks in forwarding. Dr.Pi
Have you considered handling the
WM_DESTROY
message? This will handle all methods of your app closing ("X", Alt+F4, File/Exit).
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
-
Have you considered handling the
WM_DESTROY
message? This will handle all methods of your app closing ("X", Alt+F4, File/Exit).
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
-
In my CFormView? In my App? I've tried in my CFormView but the app is closing anyway. I miss something to do? Dr.Pi
doctorpi wrote:
In my CFormView?
Yes.
doctorpi wrote:
I've tried in my CFormView but the app is closing anyway.
Are you still calling the base-class implementation. What does the
OnDestroy()
method look like?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
-
In my CFormView? In my App? I've tried in my CFormView but the app is closing anyway. I miss something to do? Dr.Pi
How about in response to WM_SYSCOMMAND where wParam==SC_CLOSE? This should be done in the app main window, wherever that is.
"If you can dodge a wrench, you can dodge a ball."
-
Hi guys I was wandering where I have to put this... ----------------------------------------------------------------------- int ret=AfxMessageBox("You will exit the program.\nContinue?",MB_YESNO); if (ret==IDNO) return ; (someone more is needed ?) ----------------------------------------------------------------------- ...in my SDI application when someone clicks on the right upper Cross (standard close button) of my app. Thanks in forwarding. Dr.Pi
Override the WM_CLOSE message (OnClose) in your MainFrame class, and put your code it there. It will catch the X in the uppoer right corner, as well as Alt-F4, or an attempt to close from the task manager. Hope that helps.
Karl - WK5M PP-ASEL-IA (N43CS) PGP Key: 0xDB02E193 PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
-
Override the WM_CLOSE message (OnClose) in your MainFrame class, and put your code it there. It will catch the X in the uppoer right corner, as well as Alt-F4, or an attempt to close from the task manager. Hope that helps.
Karl - WK5M PP-ASEL-IA (N43CS) PGP Key: 0xDB02E193 PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
-
Hi guys I was wandering where I have to put this... ----------------------------------------------------------------------- int ret=AfxMessageBox("You will exit the program.\nContinue?",MB_YESNO); if (ret==IDNO) return ; (someone more is needed ?) ----------------------------------------------------------------------- ...in my SDI application when someone clicks on the right upper Cross (standard close button) of my app. Thanks in forwarding. Dr.Pi
The recommended place for a close confirmation is in an overload of
CanCloseFrame()
in yourCDocument
-derived class.--Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ Ford, what's this fish doing in my ear?
-
The recommended place for a close confirmation is in an overload of
CanCloseFrame()
in yourCDocument
-derived class.--Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ Ford, what's this fish doing in my ear?