Dialog death
-
What does clicking the "X" box in the upper right corner of a dialog do? I'm puzzled by the behavior I am observing, and would like to understand it better. Below I describe two situations with very different results which seem to depend on clicking that box. SITUATION A
void CDlgControl::OnBUTTONCreateLadder() { pLD = new CLadder; } void CDlgControl::OnBUTTONTestButton() { pLD->DestroyWindow(); delete pLD; pLD = NULL; }
In SITUATION A above, the dialog is created and displayed. Debug shows it progressing through each command inOnBUTTONTestButton().
Debug then traces it through many Windows functions until it finally reaches a window titled Disassembly where it fails on a command 7E41B517 call 7E4194A4 Debug assertion failure File Winocc.cpp When not using Debug, it simply fails on the same message SITUATION B The same exact code is used. However, prior to executingOnBUTTONTestButton(),
I click the "X" box in the upper right corner of the CLadder window. Then I executeOnBUTTONTestButton(),
and everything works just fine. QUESTION: What does that "X" box do? What makes SITUATION A different from SITUATION B? Thanks -
What does clicking the "X" box in the upper right corner of a dialog do? I'm puzzled by the behavior I am observing, and would like to understand it better. Below I describe two situations with very different results which seem to depend on clicking that box. SITUATION A
void CDlgControl::OnBUTTONCreateLadder() { pLD = new CLadder; } void CDlgControl::OnBUTTONTestButton() { pLD->DestroyWindow(); delete pLD; pLD = NULL; }
In SITUATION A above, the dialog is created and displayed. Debug shows it progressing through each command inOnBUTTONTestButton().
Debug then traces it through many Windows functions until it finally reaches a window titled Disassembly where it fails on a command 7E41B517 call 7E4194A4 Debug assertion failure File Winocc.cpp When not using Debug, it simply fails on the same message SITUATION B The same exact code is used. However, prior to executingOnBUTTONTestButton(),
I click the "X" box in the upper right corner of the CLadder window. Then I executeOnBUTTONTestButton(),
and everything works just fine. QUESTION: What does that "X" box do? What makes SITUATION A different from SITUATION B? ThanksThe "X" button issues a
WM_SYSCOMMAND
[^] notification to be sent to the window, with thewParam
value set toSC_CLOSE
. The default window handling closes the window. With situation B, the window has already been destroyed by the timeOnBUTTONTestButton
is called, so a great deal of the normal window shutdown logic has already occurred. There's something wrong in the way you're handling the window destruction, or possibly in theCLadder
destructor. Without seeing more of theCLadder
code, it's difficult to say.
Software Zen:
delete this;
-
What does clicking the "X" box in the upper right corner of a dialog do? I'm puzzled by the behavior I am observing, and would like to understand it better. Below I describe two situations with very different results which seem to depend on clicking that box. SITUATION A
void CDlgControl::OnBUTTONCreateLadder() { pLD = new CLadder; } void CDlgControl::OnBUTTONTestButton() { pLD->DestroyWindow(); delete pLD; pLD = NULL; }
In SITUATION A above, the dialog is created and displayed. Debug shows it progressing through each command inOnBUTTONTestButton().
Debug then traces it through many Windows functions until it finally reaches a window titled Disassembly where it fails on a command 7E41B517 call 7E4194A4 Debug assertion failure File Winocc.cpp When not using Debug, it simply fails on the same message SITUATION B The same exact code is used. However, prior to executingOnBUTTONTestButton(),
I click the "X" box in the upper right corner of the CLadder window. Then I executeOnBUTTONTestButton(),
and everything works just fine. QUESTION: What does that "X" box do? What makes SITUATION A different from SITUATION B? ThanksModalDialog should call EndDialog instead of DestoryWindow, then you could delete the pointer of Dialog Variable.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
Never mind - my own stupidity is the source of every "problem" - Mixturecheers, Alok Gupta VC Forum Q&A :- I/IV Support CRY- Child Relief and You
-
What does clicking the "X" box in the upper right corner of a dialog do? I'm puzzled by the behavior I am observing, and would like to understand it better. Below I describe two situations with very different results which seem to depend on clicking that box. SITUATION A
void CDlgControl::OnBUTTONCreateLadder() { pLD = new CLadder; } void CDlgControl::OnBUTTONTestButton() { pLD->DestroyWindow(); delete pLD; pLD = NULL; }
In SITUATION A above, the dialog is created and displayed. Debug shows it progressing through each command inOnBUTTONTestButton().
Debug then traces it through many Windows functions until it finally reaches a window titled Disassembly where it fails on a command 7E41B517 call 7E4194A4 Debug assertion failure File Winocc.cpp When not using Debug, it simply fails on the same message SITUATION B The same exact code is used. However, prior to executingOnBUTTONTestButton(),
I click the "X" box in the upper right corner of the CLadder window. Then I executeOnBUTTONTestButton(),
and everything works just fine. QUESTION: What does that "X" box do? What makes SITUATION A different from SITUATION B? ThanksYou may want to use Spy++ (it comes with Visual Studio) to see what messages are being passed to windows ;)
Florin Crişan