X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/6aab927940dd5896e115e4ac9485a238ec4aeec3..c363ead1e206e599d6564ac939ac7342d165e0e3:/src/common/popupcmn.cpp diff --git a/src/common/popupcmn.cpp b/src/common/popupcmn.cpp index 1e789810b1..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