+ 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
+ // ignored as the return value would be 0 -- so forcefully give it a
+ // non default background brush in this case
+ if ( !hbr && m_hasFgCol )
+ colBg = GetBackgroundColour();
+ }
+
+ // use the background colour override if a valid colour is given: this is
+ // used when the control is disabled to grey it out and also if colBg was
+ // set just above
+ if ( colBg.IsOk() )
+ {
+ wxBrush *brush = wxTheBrushList->FindOrCreateBrush(colBg);
+ hbr = (WXHBRUSH)brush->GetResourceHandle();
+ }