Defining source of wxEVT_CLOSE_WINDOW event Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
sergey5
In need of some credit
In need of some credit
Posts: 2
Joined: Tue Feb 26, 2013 4:28 pm

Defining source of wxEVT_CLOSE_WINDOW event

Post by sergey5 » Tue Feb 26, 2013 4:40 pm

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.

User avatar
doublemax
Moderator
Moderator
Posts: 15184
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Defining source of wxEVT_CLOSE_WINDOW event

Post by doublemax » Tue Feb 26, 2013 5:30 pm

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
Use the source, Luke!

Radek
Super wx Problem Solver
Super wx Problem Solver
Posts: 286
Joined: Sun Sep 11, 2011 7:17 am

Re: Defining source of wxEVT_CLOSE_WINDOW event

Post by Radek » Tue Feb 26, 2013 5:35 pm

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().

sergey5
In need of some credit
In need of some credit
Posts: 2
Joined: Tue Feb 26, 2013 4:28 pm

Re: Defining source of wxEVT_CLOSE_WINDOW event

Post by sergey5 » Wed Feb 27, 2013 10:20 am

Thanks a lot doublemax, your advise realy helped me to resolve problem.

Post Reply