X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/017dc06b502c041c112a3948e6c5f65000a86d94..4e15d1caa03346c126015019c1fdf093033ef40b:/src/msw/control.cpp?ds=sidebyside diff --git a/src/msw/control.cpp b/src/msw/control.cpp index 19151d7854..6fe928cc57 100644 --- a/src/msw/control.cpp +++ b/src/msw/control.cpp @@ -367,7 +367,23 @@ WXHBRUSH wxControl::DoMSWControlColor(WXHDC pDC, wxColour colBg, WXHWND hWnd) WXHBRUSH hbr = 0; if ( !colBg.IsOk() ) { - if ( wxWindow *win = wxFindWinFromHandle(hWnd) ) + wxWindow *win = wxFindWinFromHandle( hWnd ); + if ( !win ) + { + // If this HWND doesn't correspond to a wxWindow, it still might be + // one of its children for which we need to set the background + // brush, e.g. this is the case for the EDIT control that is part + // of wxComboBox. Check for this by asking the parent if it has it: + HWND parent = ::GetParent(hWnd); + if ( parent ) + { + wxWindow *winParent = wxFindWinFromHandle( parent ); + if( winParent && winParent->ContainsHWND( hWnd ) ) + win = winParent; + } + } + + if ( win ) hbr = win->MSWGetBgBrush(pDC); // if the control doesn't have any bg colour, foreground colour will be