Fix setting colours for the edit control part of wxComboBox.

Recognize this control as part of wxComboBox and so handle WM_CTLCOLOR for it.

To do this, override ContainsHWND() in wxComboBox and use it, on the parent
window, in wxControl::DoMSWControlColor(), if we fail to find the window
directly.

Closes #811.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72468 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2012-09-13 17:11:56 +00:00
parent d07f2e1918
commit 5ddb3b8c53
4 changed files with 24 additions and 1 deletions

View File

@@ -557,6 +557,7 @@ wxGTK:
wxMSW: wxMSW:
- Fix setting colours for the text part of wxComboBox (Igor Korot).
- Add support for CURRENCY and SCODE types to OLE Automation helpers (PB). - Add support for CURRENCY and SCODE types to OLE Automation helpers (PB).
- Allow setting LCID used by wxAutomationObject (PB). - Allow setting LCID used by wxAutomationObject (PB).
- Fix calling Iconize(false) on hidden top level windows (Christian Walther). - Fix calling Iconize(false) on hidden top level windows (Christian Walther).

View File

@@ -92,6 +92,7 @@ public:
virtual void SetSelection(long from, long to) virtual void SetSelection(long from, long to)
{ wxTextEntry::SetSelection(from, to); } { wxTextEntry::SetSelection(from, to); }
virtual int GetSelection() const { return wxChoice::GetSelection(); } virtual int GetSelection() const { return wxChoice::GetSelection(); }
virtual bool ContainsHWND(WXHWND hWnd) const;
virtual void GetSelection(long *from, long *to) const; virtual void GetSelection(long *from, long *to) const;
virtual bool IsEditable() const; virtual bool IsEditable() const;

View File

@@ -550,6 +550,11 @@ void wxComboBox::Clear()
wxTextEntry::Clear(); wxTextEntry::Clear();
} }
bool wxComboBox::ContainsHWND(WXHWND hWnd) const
{
return hWnd == GetEditHWNDIfAvailable();
}
void wxComboBox::GetSelection(long *from, long *to) const void wxComboBox::GetSelection(long *from, long *to) const
{ {
if ( !HasFlag(wxCB_READONLY) ) if ( !HasFlag(wxCB_READONLY) )

View File

@@ -367,7 +367,23 @@ WXHBRUSH wxControl::DoMSWControlColor(WXHDC pDC, wxColour colBg, WXHWND hWnd)
WXHBRUSH hbr = 0; WXHBRUSH hbr = 0;
if ( !colBg.IsOk() ) 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); hbr = win->MSWGetBgBrush(pDC);
// if the control doesn't have any bg colour, foreground colour will be // if the control doesn't have any bg colour, foreground colour will be