From 582699e1ac533e85ba62ae320c6e922ad1685bec Mon Sep 17 00:00:00 2001 From: Jaakko Salli Date: Tue, 25 Nov 2008 17:04:48 +0000 Subject: [PATCH] To avoid error message, do not even try to set focus on MSW popup window that doesn't have WS_POPUP style (closes #10157) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@56968 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/popupcmn.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/common/popupcmn.cpp b/src/common/popupcmn.cpp index 1e789810b1..98eb20b873 100644 --- a/src/common/popupcmn.cpp +++ b/src/common/popupcmn.cpp @@ -260,8 +260,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