From b932b899af1e69c391de0c7f65cbafe9990ed95d Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 3 Aug 2014 12:47:20 +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/trunk@76984 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/control.cpp | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/src/msw/control.cpp b/src/msw/control.cpp index 2543d5f6f7..d76e91ebef 100644 --- a/src/msw/control.cpp +++ b/src/msw/control.cpp @@ -380,14 +380,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 )