X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/7561aacd5e3bcd5f98f4cdadcec5e94d1550b369..030c0beade81092da145abc94b2750cd11a3be0b:/src/msw/window.cpp diff --git a/src/msw/window.cpp b/src/msw/window.cpp index 184d7da24b..7b171f9f7c 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -288,12 +288,27 @@ 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()) + { + wxFrame *frame = wxDynamicCast(win, wxFrame); + if ( frame ) + { + if ( frame->GetLastFocus() == this ) + frame->SetLastFocus((wxWindow*)NULL); + 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 @@ -2246,13 +2261,7 @@ long wxWindow::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam) wxPoint pt(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); wxContextMenuEvent evtCtx(wxEVT_CONTEXT_MENU, GetId(), pt); - GetEventHandler()->ProcessEvent(evtCtx); - - // set processed to true even if the event is not handled - // because if we don't windows will propogate the - // WM_CONTEXTMENU up the parent window chain, which we have - // already done ourselves. - processed = true; + processed = GetEventHandler()->ProcessEvent(evtCtx); } break; #endif // __WIN32__