X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/9a8909371b50c92753af2ab6d432aa8124122ec1..86c5b12b21333e9817bd2d0c21458308390e1524:/src/common/popupcmn.cpp?ds=sidebyside diff --git a/src/common/popupcmn.cpp b/src/common/popupcmn.cpp index bef08770aa..9347bd3432 100644 --- a/src/common/popupcmn.cpp +++ b/src/common/popupcmn.cpp @@ -43,9 +43,10 @@ #ifdef __WXGTK__ #include -#endif -#ifdef __WXX11__ -#include "wx/x11/private.h" +#elif defined(__WXMSW__) + #include "wx/msw/private.h" +#elif defined(__WXX11__) + #include "wx/x11/private.h" #endif IMPLEMENT_DYNAMIC_CLASS(wxPopupWindow, wxWindow) @@ -260,8 +261,16 @@ void wxPopupTransientWindow::Popup(wxWindow *winFocus) m_child->PushEventHandler(m_handlerPopup); - m_focus = winFocus ? winFocus : this; - m_focus->SetFocus(); +#if defined(__WXMSW__) + // Focusing on child of popup window does not work on MSW unless WS_POPUP + // style is set. We do not even want to try to set the focus, as it may + // provoke errors on some Windows versions (Vista and later). + if ( ::GetWindowLong(GetHwnd(), GWL_STYLE) & WS_POPUP ) +#endif + { + m_focus = winFocus ? winFocus : this; + m_focus->SetFocus(); + } #if defined( __WXMSW__ ) || defined( __WXMAC__) // MSW doesn't allow to set focus to the popup window, but we need to @@ -507,7 +516,7 @@ void wxPopupWindowHandler::OnLeftDown(wxMouseEvent& event) winUnder->ScreenToClient(&event2.m_x, &event2.m_y); event2.SetEventObject(winUnder); - wxPostEvent(winUnder, event2); + wxPostEvent(winUnder->GetEventHandler(), event2); } } break;