Add MSWGetFocusHWND to allow focus a subwindow

Under MSW allow override which subwindow will be focused for composite
windows which are implemented not as a set of wxControl (i.e. using only
Windows native controls).
This commit is contained in:
Ilya Sinitsyn
2019-11-01 00:19:53 +07:00
parent 53c5ebedca
commit 1b6dc0a2fb
3 changed files with 11 additions and 3 deletions

View File

@@ -577,7 +577,7 @@ void wxWindowMSW::SetId(wxWindowID winid)
void wxWindowMSW::SetFocus()
{
HWND hWnd = GetHwnd();
HWND hWnd = MSWGetFocusHwnd();
wxCHECK_RET( hWnd, wxT("can't set focus to invalid window") );
::SetLastError(0);
@@ -599,13 +599,15 @@ void wxWindowMSW::SetFocus()
void wxWindowMSW::SetFocusFromKbd()
{
HWND hWnd = MSWGetFocusHwnd();
// when the focus is given to the control with DLGC_HASSETSEL style from
// keyboard its contents should be entirely selected: this is what
// ::IsDialogMessage() does and so we should do it as well to provide the
// same LNF as the native programs
if ( ::SendMessage(GetHwnd(), WM_GETDLGCODE, 0, 0) & DLGC_HASSETSEL )
if ( ::SendMessage(hWnd, WM_GETDLGCODE, 0, 0) & DLGC_HASSETSEL )
{
::SendMessage(GetHwnd(), EM_SETSEL, 0, -1);
::SendMessage(hWnd, EM_SETSEL, 0, -1);
}
// do this after (maybe) setting the selection as like this when