diff --git a/docs/changes.txt b/docs/changes.txt index e6bb2f0e98..49939c7e98 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -557,6 +557,7 @@ wxGTK: wxMSW: +- Fix setting colours for the text part of wxComboBox (Igor Korot). - Add support for CURRENCY and SCODE types to OLE Automation helpers (PB). - Allow setting LCID used by wxAutomationObject (PB). - Fix calling Iconize(false) on hidden top level windows (Christian Walther). diff --git a/include/wx/msw/combobox.h b/include/wx/msw/combobox.h index 191ebb3f90..aa10c8dd93 100644 --- a/include/wx/msw/combobox.h +++ b/include/wx/msw/combobox.h @@ -92,6 +92,7 @@ public: virtual void SetSelection(long from, long to) { wxTextEntry::SetSelection(from, to); } virtual int GetSelection() const { return wxChoice::GetSelection(); } + virtual bool ContainsHWND(WXHWND hWnd) const; virtual void GetSelection(long *from, long *to) const; virtual bool IsEditable() const; diff --git a/src/msw/combobox.cpp b/src/msw/combobox.cpp index d9b39e7d30..46b1c482c1 100644 --- a/src/msw/combobox.cpp +++ b/src/msw/combobox.cpp @@ -550,6 +550,11 @@ void wxComboBox::Clear() wxTextEntry::Clear(); } +bool wxComboBox::ContainsHWND(WXHWND hWnd) const +{ + return hWnd == GetEditHWNDIfAvailable(); +} + void wxComboBox::GetSelection(long *from, long *to) const { if ( !HasFlag(wxCB_READONLY) ) 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