Page 1 of 1

Defining source of wxEVT_CLOSE_WINDOW event

Posted: Tue Feb 26, 2013 4:40 pm
by sergey5
Hi all,

I have faced with problem (OS Windows 7) - I need to separate reaction on wxEVT_CLOSE_WINDOW event in context shutdown/restart OS from one side and close button ("X" button in window header) click from another side. Both of these reactions work through wxWindowBase::Close(bool force) method, so I don't understand how I can separate them.

Thank to all who could push me in right direction.

Re: Defining source of wxEVT_CLOSE_WINDOW event

Posted: Tue Feb 26, 2013 5:30 pm
by doublemax
Use the wxEVT_QUERY_END_SESSION and wxEVT_END_SESSION events. You need to catch them at wxApp level.

http://docs.wxwidgets.org/stable/wx_wxc ... closeevent

The events are directly related to the MSW WM_QUERYENDSESSION and WM_ENDSESSION messages.
http://msdn.microsoft.com/en-us/library ... 85%29.aspx
http://msdn.microsoft.com/en-us/library ... 85%29.aspx

Re: Defining source of wxEVT_CLOSE_WINDOW event

Posted: Tue Feb 26, 2013 5:35 pm
by Radek
Also, during shutdown the close event cannot be vetoed for sure, if the close comes from the 'x' button or a button calling Close() then it can be vetoed. Check with CanVeto().

Re: Defining source of wxEVT_CLOSE_WINDOW event

Posted: Wed Feb 27, 2013 10:20 am
by sergey5
Thanks a lot doublemax, your advise realy helped me to resolve problem.