X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ebfee17940b5123d0527b63bcf23e5f27002092e..24b4db9b0de92ef5c899b98a556f8cd09ad1fc54:/src/msw/statbox.cpp diff --git a/src/msw/statbox.cpp b/src/msw/statbox.cpp index 3c2dfcf06d..1058f381b9 100644 --- a/src/msw/statbox.cpp +++ b/src/msw/statbox.cpp @@ -237,6 +237,24 @@ WXLRESULT wxStaticBox::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lPar return 0; } + if ( nMsg == WM_UPDATEUISTATE ) + { + // DefWindowProc() redraws just the static box text when it gets this + // message and it does it using the standard (blue in standard theme) + // colour and not our own label colour that we use in PaintForeground() + // resulting in the label mysteriously changing the colour when e.g. + // "Alt" is pressed anywhere in the window, see #12497. + // + // To avoid this we simply refresh the window forcing our own code + // redrawing the label in the correct colour to be called. This is + // inefficient but there doesn't seem to be anything else we can do. + // + // Notice that the problem is XP-specific and doesn't arise under later + // systems. + if ( m_hasFgCol && wxGetWinVersion() == wxWinVersion_XP ) + Refresh(); + } + return wxControl::MSWWindowProc(nMsg, wParam, lParam); } @@ -494,18 +512,32 @@ void wxStaticBox::PaintForeground(wxDC& dc, const RECT& rc) PaintBackground(dc, dimensions); } + UINT drawTextFlags = DT_SINGLELINE | DT_VCENTER; + + // determine the state of UI queues to draw the text correctly under XP + // and later systems + static const bool isXPorLater = wxGetWinVersion() >= wxWinVersion_XP; + if ( isXPorLater ) + { + if ( ::SendMessage(GetHwnd(), WM_QUERYUISTATE, 0, 0) & + UISF_HIDEACCEL ) + { + drawTextFlags |= DT_HIDEPREFIX; + } + } + // now draw the text if ( !rtl ) { RECT rc2 = { x, 0, x + width, y }; ::DrawText(hdc, label.wx_str(), label.length(), &rc2, - DT_SINGLELINE | DT_VCENTER); + drawTextFlags); } else // RTL { RECT rc2 = { x, 0, x - width, y }; ::DrawText(hdc, label.wx_str(), label.length(), &rc2, - DT_SINGLELINE | DT_VCENTER | DT_RTLREADING); + drawTextFlags | DT_RTLREADING); } } }