Reputation: 311
I have application in Visual C++ which catches the window messages when the program is terminated by for instance closing the window by pushing the "X" on the right upper corner. Here, it follows the regular process: WM_CLOSE
-> WM_DESTROY
-> WM_QUIT
.
long FAR PASCAL MAIN_WindowProc( HWND hWnd,
UINT message,
WPARAM wParam,
LPARAM lParam )
{
...
case WM_CLOSE:
{
if ( Game() && pcgaming()->active )
{
if ( Game()->MainStatus != MAINSTATUS_SHUTTINGDOWN )
{
Game()->Exit_To_Windows = true;
Game()->ExitNow( EXIT_ESCAPE );
}
}
return (long) 0;
}break;
...
When you stop running an application in Visual Studio by either pushing its button or selecting Shift + F5, how is the program actually terminated ? is there any messages to catch like WM_XXX ?
Upvotes: 0
Views: 576
Reputation: 456
When you press Shift+F5 (assuming you started from Visual Studio), the debugger directly and immediately kills the child process. No message or notification is sent to the program whatsoever.
If you have started with Ctrl+F5 and later attached manually, then Shift+F5 would detach and the program would keep running. You could then poll for IsDebuggerPresent(), since you would not close down. Though it is not clear why you would want to do that.
You can check the list of all functions that the debugger and debugee can use to communicate, but it is basically all for the debugee to send extra debugging info to the debugger. The debugee can know whether a debugger is attach, but is not notified when it is about to detach (or kill it).
Upvotes: 1