views:

186

answers:

2

My wxwidgets program does not allow the computer to shutdown when the user clicks on Shutdown. I had issues with exiting the program normally so I've been calling exit() directly instead of deleting the top window as wxwidgets says to do. The exit workaround has been working but it seems wxwidgets can't exit when it receives shutdown window signal (?). Can I trap this somehow and just call exit so that the program does not block windows from shutting down?

+1  A: 

When Windows is shutting down it posts WM_SHUTDOWN message to all applications that have window

Are you able to catch that message?

Vadmyst
+2  A: 

Windows sends the WM_SHUTDOWN message to all applications. This event is mapped to EVT_END_SESSION in your wxWidgets application. Make sure you handle this event appropriately.

See the wxCloseEvent Class Reference.

In case of problems also try handling EVT_QUERY_END_SESSION, which is related to WM_QUERY_END_SESSION. This message is send before WM_SHUTDOWN to give applications the possibility to cancel the shutdown.

DR
Kde23
Updated my answer.
DR