]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/choice.cpp
Fixed a long-standing issue where wxSlider controls with a hardcoded size would mispl...
[wxWidgets.git] / src / msw / choice.cpp
index 7d293875c9e926948ef45fa5bde3533fa357fb57..b7feab4c5bc490b52e47349a177a2a6abfbf6aac 100644 (file)
@@ -504,6 +504,23 @@ void wxChoice::DoSetSize(int x, int y,
         const int hItem = SendMessage(GetHwnd(), CB_GETITEMHEIGHT, 0, 0);
         height += hItem*(nItems + 1);
     }
         const int hItem = SendMessage(GetHwnd(), CB_GETITEMHEIGHT, 0, 0);
         height += hItem*(nItems + 1);
     }
+    else
+    {
+        // We cannot pass wxDefaultCoord as height to wxControl. wxControl uses
+        // wxGetWindowRect() to determine the current height of the combobox, 
+        // and then again sets the combobox's height to that value. Unfortunately, 
+        // wxGetWindowRect doesn't include the dropdown list's height (at least 
+        // on Win2K), so this would result in a combobox with dropdown height of 
+        // 1 pixel. We have to determine the default height ourselves and call
+        // wxControl with that value instead.
+        int w, h;
+        RECT r;
+        DoGetSize(&w, &h);
+        if (::SendMessage(GetHwnd(), CB_GETDROPPEDCONTROLRECT, 0, (LPARAM) &r) != 0)
+        {
+            height = h + r.bottom - r.top;       
+        }
+    }
 
     wxControl::DoSetSize(x, y, width, height, sizeFlags);
 
 
     wxControl::DoSetSize(x, y, width, height, sizeFlags);
 
@@ -582,8 +599,10 @@ WXLRESULT wxChoice::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
                 WXHWND hwnd;
                 UnpackCtlColor(wParam, lParam, &hdc, &hwnd);
 
                 WXHWND hwnd;
                 UnpackCtlColor(wParam, lParam, &hdc, &hwnd);
 
-                return (WXLRESULT)OnCtlColor(hdc, hwnd, 0,
-                                             nMsg, wParam, lParam);
+                WXHBRUSH hbr = MSWControlColor((WXHDC)hdc);
+                if ( hbr )
+                    return (WXLRESULT)hbr;
+                //else: fall through to default window proc
             }
     }
 
             }
     }
 
@@ -615,24 +634,13 @@ bool wxChoice::MSWCommand(WXUINT param, WXWORD WXUNUSED(id))
     return true;
 }
 
     return true;
 }
 
-WXHBRUSH wxChoice::OnCtlColor(WXHDC pDC, WXHWND WXUNUSED(pWnd), WXUINT WXUNUSED(nCtlColor),
-                               WXUINT WXUNUSED(message),
-                               WXWPARAM WXUNUSED(wParam),
-                               WXLPARAM WXUNUSED(lParam)
-     )
+WXHBRUSH wxChoice::MSWControlColor(WXHDC hDC)
 {
 {
-    HDC hdc = (HDC)pDC;
-    wxColour colBack = GetBackgroundColour();
+    if ( !IsEnabled() )
+        return MSWControlColorDisabled(hDC);
 
 
-    if (!IsEnabled())
-        colBack = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE);
-
-    ::SetBkColor(hdc, wxColourToRGB(colBack));
-    ::SetTextColor(hdc, wxColourToRGB(GetForegroundColour()));
-
-    wxBrush *brush = wxTheBrushList->FindOrCreateBrush(colBack, wxSOLID);
-
-    return (WXHBRUSH)brush->GetResourceHandle();
+    return wxChoiceBase::MSWControlColorSolid(hDC);
 }
 
 #endif // wxUSE_CHOICE && !(__SMARTPHONE__ && __WXWINCE__)
 }
 
 #endif // wxUSE_CHOICE && !(__SMARTPHONE__ && __WXWINCE__)
+