X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/dbae17a2e0553c54eb6e69d64cda95a6ac4595ad..93a21d8885344c49947d0cadd1e76be8dadd94b0:/src/msw/window.cpp diff --git a/src/msw/window.cpp b/src/msw/window.cpp index fb7bb67368..fb93646628 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -84,7 +84,7 @@ #include -#ifndef __GNUWIN32_OLD__ +#if !defined(__GNUWIN32_OLD__) || defined(__CYGWIN10__) #include #include #endif @@ -93,7 +93,7 @@ #include #endif -#if !defined(__GNUWIN32_OLD__) && !defined(__TWIN32__) +#if (!defined(__GNUWIN32_OLD__) && !defined(__TWIN32__)) || defined(__CYGWIN10__) #ifdef __WIN95__ #include #endif @@ -288,7 +288,7 @@ wxWindow::~wxWindow() m_isBeingDeleted = TRUE; MSWDetachWindowMenu(); - + // VS: make sure there's no wxFrame with last focus set to us: for (wxWindow *win = GetParent(); win; win = win->GetParent()) { @@ -297,15 +297,18 @@ wxWindow::~wxWindow() { if ( frame->GetLastFocus() == this ) frame->SetLastFocus((wxWindow*)NULL); - //break; + break; } } + // VS: destroy children first and _then_ detach *this from its parent. + // If we'd do it the other way around, children wouldn't be able + // find their parent frame (see above). + DestroyChildren(); + if ( m_parent ) m_parent->RemoveChild(this); - DestroyChildren(); - if ( m_hWnd ) { // VZ: test temp removed to understand what really happens here @@ -443,7 +446,11 @@ bool wxWindow::Show(bool show) // Raise the window to the top of the Z order void wxWindow::Raise() { +#ifdef __WIN16__ ::BringWindowToTop(GetHwnd()); +#else // Win32 + ::SetForegroundWindow(GetHwnd()); +#endif } // Lower the window to the bottom of the Z order @@ -1481,6 +1488,23 @@ void wxWindow::GetCaretPos(int *x, int *y) const // popup menu // --------------------------------------------------------------------------- +// yield for WM_COMMAND events only, i.e. process all WM_COMMANDs in the queue +// immediately, without waiting for the next event loop iteration +// +// NB: this function should probably be made public later as it can almost +// surely replace wxYield() elsewhere as well +static void wxYieldForCommandsOnly() +{ + // peek all WM_COMMANDs (it will always return WM_QUIT too but we don't + // want to process it here) + MSG msg; + while ( ::PeekMessage(&msg, (HWND)0, WM_COMMAND, WM_COMMAND, PM_REMOVE) + && msg.message != WM_QUIT ) + { + wxTheApp->DoMessage((WXMSG *)&msg); + } +} + bool wxWindow::DoPopupMenu(wxMenu *menu, int x, int y) { menu->SetInvokingWindow(this); @@ -1494,7 +1518,16 @@ bool wxWindow::DoPopupMenu(wxMenu *menu, int x, int y) ::ClientToScreen(hWnd, &point); wxCurrentPopupMenu = menu; ::TrackPopupMenu(hMenu, TPM_RIGHTBUTTON, point.x, point.y, 0, hWnd, NULL); - wxYieldIfNeeded(); + + // we need to do it righ now as otherwise the events are never going to be + // sent to wxCurrentPopupMenu from HandleCommand() + // + // note that even eliminating (ugly) wxCurrentPopupMenu global wouldn't + // help and we'd still need wxYieldForCommandsOnly() as the menu may be + // destroyed as soon as we return (it can be a local variable in the caller + // for example) and so we do need to process the event immediately + wxYieldForCommandsOnly(); + wxCurrentPopupMenu = NULL; menu->SetInvokingWindow(NULL); @@ -3432,6 +3465,9 @@ bool wxWindow::HandleMouseWheel(WXWPARAM wParam, WXLPARAM lParam) return GetEventHandler()->ProcessEvent(event); #else + (void) wParam; + (void) lParam; + return FALSE; #endif }