X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/9741fd45f734ea30e094f5b15f092b8394621204..17d98558b35b75e3cad68d96841b4fa5a0c7e6ee:/src/msw/window.cpp diff --git a/src/msw/window.cpp b/src/msw/window.cpp index 5dd89b0bc3..117141a4ea 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -699,9 +699,21 @@ wxWindow *wxWindowBase::DoFindFocus() void wxWindowMSW::DoEnable( bool enable ) { - HWND hWnd = GetHwnd(); - if ( hWnd ) - ::EnableWindow(hWnd, (BOOL)enable); + MSWEnableHWND(GetHwnd(), enable); +} + +bool wxWindowMSW::MSWEnableHWND(WXHWND hWnd, bool enable) +{ + if ( !hWnd ) + return false; + + // If disabling focused control, we move focus to the next one, as if the + // user pressed Tab. That's because we can't keep focus on a disabled + // control, Tab-navigation would stop working then. + if ( !enable && ::GetFocus() == hWnd ) + Navigate(); + + return ::EnableWindow(hWnd, (BOOL)enable) != 0; } bool wxWindowMSW::Show(bool show)