From 51dbcf35ffc6b4560fd00c913dcf9fdf88e42faf Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 5 Oct 2002 21:33:01 +0000 Subject: [PATCH] call SetFocus() in WM_LBUTTONDOWN handler for the wxWindows controls (not standard ones) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@17463 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/window.cpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/msw/window.cpp b/src/msw/window.cpp index c79e87c99c..1048795032 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -2483,14 +2483,6 @@ long wxWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam break; #endif // __WXMICROWIN__ - // VZ: if you find a situation when this is needed, tell - // me about it, do *not* uncomment this code as it - // causes other strange problems -#if 0 - if ( message == WM_LBUTTONDOWN && AcceptsFocus() ) - SetFocus(); -#endif // 0 - int x = GET_X_LPARAM(lParam), y = GET_Y_LPARAM(lParam); @@ -2506,6 +2498,20 @@ long wxWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam else { win = FindWindowForMouseEvent(this, &x, &y); + + // this should never happen + wxCHECK_MSG( win, 0, + _T("FindWindowForMouseEvent() returned NULL") ); + + // for the standard classes their WndProc sets the focus to + // them anyhow and doing it from here results in some weird + // problems, but for our windows we want them to acquire + // focus when clicked + if ( !win->IsOfStandardClass() ) + { + if ( message == WM_LBUTTONDOWN && win->AcceptsFocus() ) + win->SetFocus(); + } } processed = win->HandleMouseEvent(message, x, y, wParam);