]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/control.cpp
Compilation fix for !wxUSE_OWNER_DRAWN.
[wxWidgets.git] / src / msw / control.cpp
index 19151d7854f1c37beab4c6e6a86745e1afe3cd51..1fe94bab92d8dd77feb06257e66c2f301a159cdb 100644 (file)
@@ -4,7 +4,6 @@
 // Author:      Julian Smart
 // Modified by:
 // Created:     01/02/97
-// RCS-ID:      $Id$
 // Copyright:   (c) Julian Smart
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
@@ -367,7 +366,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