From 8b38ba9726db94bb71f02a64cf74ed6b8f42a42f Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 25 Jul 2014 17:34:07 +0000 Subject: [PATCH] Fix background of wxRadioBox buttons and wxSlider labels in wxMSW. Handle WM_CTLCOLOR correctly for them, this wasn't done before because the code assumed that sub-windows (i.e. HWNDs which belong to the same logical wx control) were always children of the main window, but they could also be its siblings (like in at least the two above mentioned cases). Account for this case in wxControl::DoMSWControlColor() too now. Closes #12271. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_3_0_BRANCH@76950 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 1 + src/msw/control.cpp | 26 +++++++++++++++++++------- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index c4605bcd8b..54e16d4493 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -595,6 +595,7 @@ wxMSW: - Fix Cygwin 1.7 build. - Include x64 configurations in MSVC 8/9 project files too. - Fix parallel build of MSVC 11/12 solutions (Artur Wieczorek). +- Fix background of wxRadioBox buttons and wxSlider (Artur Wieczorek). - Fix appearance of wxToggleButtons with non default colours (Artur Wieczorek). diff --git a/src/msw/control.cpp b/src/msw/control.cpp index 4bb6ae8423..79aa30a763 100644 --- a/src/msw/control.cpp +++ b/src/msw/control.cpp @@ -372,14 +372,26 @@ WXHBRUSH wxControl::DoMSWControlColor(WXHDC pDC, wxColour colBg, WXHWND hWnd) // 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 ) + // of wxComboBox but also e.g. of wxSlider label HWNDs which are + // logically part of it, but are siblings of the main control at + // Windows level. + // + // So check whether it's a sibling of this window which is part of + // the same wx object. + if ( ContainsHWND(hWnd) ) { - wxWindow *winParent = wxFindWinFromHandle( parent ); - if( winParent && winParent->ContainsHWND( hWnd ) ) - win = winParent; - } + win = this; + } + else // Or maybe a child sub-window of this one. + { + HWND parent = ::GetParent(hWnd); + if ( parent ) + { + wxWindow *winParent = wxFindWinFromHandle( parent ); + if( winParent && winParent->ContainsHWND( hWnd ) ) + win = winParent; + } + } } if ( win )