Kde23
Kde23

Reputation: 21

My program prevents Windows from shutting down!

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?

Upvotes: 2

Views: 1075

Answers (2)

Daniel Rikowski
Daniel Rikowski

Reputation: 72514

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.

Upvotes: 2

Vadym Stetsiak
Vadym Stetsiak

Reputation: 1972

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

Are you able to catch that message?

Upvotes: 1

Related Questions