Deal with themes not implementing GetThemeBackgroundContentRect()
Some custom themes apparently don't implement this function at all and just return failure error code from it, but our code either assumed that it never failed (when handling WM_NCPAINT) or didn't handle its failure correctly (when handle WM_NCCALCSIZE the client rect wasn't returned at all to the system in this case). Fix this by just falling back to the initial rectangle in case of failure.
This commit is contained in:
@@ -3740,8 +3740,14 @@ wxWindowMSW::MSWHandleMessage(WXLRESULT *result,
|
||||
EP_EDITTEXT,
|
||||
IsEnabled() ? ETS_NORMAL : ETS_DISABLED,
|
||||
rect,
|
||||
&rcClient) == S_OK )
|
||||
&rcClient) != S_OK )
|
||||
{
|
||||
// If GetThemeBackgroundContentRect() failed, as can
|
||||
// happen with at least some custom themes, just use
|
||||
// the original client rectangle.
|
||||
rcClient = *rect;
|
||||
}
|
||||
|
||||
InflateRect(&rcClient, -1, -1);
|
||||
if (wParam)
|
||||
csparam->rgrc[0] = rcClient;
|
||||
@@ -3753,7 +3759,6 @@ wxWindowMSW::MSWHandleMessage(WXLRESULT *result,
|
||||
// rc.result = WVR_REDRAW;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_NCPAINT:
|
||||
@@ -3776,8 +3781,23 @@ wxWindowMSW::MSWHandleMessage(WXLRESULT *result,
|
||||
RECT rcClient;
|
||||
|
||||
const int nState = IsEnabled() ? ETS_NORMAL : ETS_DISABLED;
|
||||
::GetThemeBackgroundContentRect(
|
||||
hTheme, GetHdcOf(*impl), EP_EDITTEXT, nState, &rcBorder, &rcClient);
|
||||
|
||||
if ( ::GetThemeBackgroundContentRect
|
||||
(
|
||||
hTheme,
|
||||
GetHdcOf(*impl),
|
||||
EP_EDITTEXT,
|
||||
nState,
|
||||
&rcBorder,
|
||||
&rcClient
|
||||
) != S_OK )
|
||||
{
|
||||
// As above in WM_NCCALCSIZE, fall back on something
|
||||
// reasonable for themes which don't implement this
|
||||
// function.
|
||||
rcClient = rcBorder;
|
||||
}
|
||||
|
||||
InflateRect(&rcClient, -1, -1);
|
||||
|
||||
::ExcludeClipRect(GetHdcOf(*impl), rcClient.left, rcClient.top,
|
||||
|
Reference in New Issue
Block a user