added SetCriticalWindow() and AllowProcessing(): this allows to freeze all events except those for the specified window
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@34861 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
a393585a1e
commit
a7b7500c4f
@ -38,12 +38,35 @@ public:
|
||||
// process a single message
|
||||
virtual void ProcessMessage(WXMSG *msg);
|
||||
|
||||
// set the critical window: this is the window such that all the events
|
||||
// except those to this window (and its children) stop to be processed
|
||||
// (typical examples: assert or crash report dialog)
|
||||
//
|
||||
// calling this function with NULL argument restores the normal event
|
||||
// handling
|
||||
static void SetCriticalWindow(wxWindow *win) { ms_winCritical = win; }
|
||||
|
||||
// return true if there is no critical window or if this window is [a child
|
||||
// of] the critical one
|
||||
static bool AllowProcessing(wxWindow *win)
|
||||
{
|
||||
return !ms_winCritical || IsChildOfCriticalWindow(win);
|
||||
}
|
||||
|
||||
protected:
|
||||
// should we exit the loop?
|
||||
bool m_shouldExit;
|
||||
// check if the given window is a child of ms_winCritical (which must be
|
||||
// non NULL)
|
||||
static bool IsChildOfCriticalWindow(wxWindow *win);
|
||||
|
||||
|
||||
// critical window or NULL
|
||||
static wxWindow *ms_winCritical;
|
||||
|
||||
// the loop exit code
|
||||
int m_exitcode;
|
||||
|
||||
// should we exit the loop?
|
||||
bool m_shouldExit;
|
||||
};
|
||||
|
||||
#endif // _WX_MSW_EVTLOOP_H_
|
||||
|
@ -85,6 +85,7 @@ private:
|
||||
// ============================================================================
|
||||
|
||||
wxEventLoop *wxEventLoopBase::ms_activeLoop = NULL;
|
||||
wxWindow *wxEventLoop::ms_winCritical = NULL;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// ctor/dtor
|
||||
@ -111,10 +112,24 @@ void wxEventLoop::ProcessMessage(WXMSG *msg)
|
||||
}
|
||||
}
|
||||
|
||||
bool wxEventLoop::IsChildOfCriticalWindow(wxWindow *win)
|
||||
{
|
||||
while ( win )
|
||||
{
|
||||
if ( win == ms_winCritical )
|
||||
return true;
|
||||
|
||||
win = win->GetParent();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool wxEventLoop::PreProcessMessage(WXMSG *msg)
|
||||
{
|
||||
HWND hwnd = msg->hwnd;
|
||||
wxWindow *wndThis = wxGetWindowFromHWND((WXHWND)hwnd);
|
||||
wxWindow * const wndThis = wxGetWindowFromHWND((WXHWND)hwnd);
|
||||
wxWindow *wnd;
|
||||
|
||||
// this may happen if the event occurred in a standard modeless dialog (the
|
||||
// only example of which I know of is the find/replace dialog) - then call
|
||||
@ -132,6 +147,17 @@ bool wxEventLoop::PreProcessMessage(WXMSG *msg)
|
||||
return hwnd && ::IsDialogMessage(hwnd, msg) != 0;
|
||||
}
|
||||
|
||||
if ( !AllowProcessing(wndThis) )
|
||||
{
|
||||
// not a child of critical window, so we eat the event but take care to
|
||||
// stop an endless stream of WM_PAINTs which would have resulted if we
|
||||
// didn't validate the invalidated part of the window
|
||||
if ( msg->message == WM_PAINT )
|
||||
::ValidateRect(hwnd, NULL);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#if wxUSE_TOOLTIPS
|
||||
// we must relay WM_MOUSEMOVE events to the tooltip ctrl if we want it to
|
||||
// popup the tooltip bubbles
|
||||
@ -154,8 +180,6 @@ bool wxEventLoop::PreProcessMessage(WXMSG *msg)
|
||||
}
|
||||
|
||||
// try translations first: the accelerators override everything
|
||||
wxWindow *wnd;
|
||||
|
||||
for ( wnd = wndThis; wnd; wnd = wnd->GetParent() )
|
||||
{
|
||||
if ( wnd->MSWTranslateMessage((WXMSG *)msg))
|
||||
|
Loading…
Reference in New Issue
Block a user