Fix infinite recursion when resizing a TLW in wxUniv/MSW

Don't use wxClientDC in WM_NCCALCSIZE handler as creating it results in
another WM_NCCALCSIZE in wxUniv due to the call to DoSetClippingRegion()
in its wxClientDCImpl::InitDC().

Using simple WindowHDC is also a small performance gain and is all that
we need as we just need some HDC for this window and should have
probably been done like this even back in a047aff270 (Added
wxBORDER_THEME..., 2007-08-07) in which handling WM_NCCALCSIZE was
added.

Closes #19221.
This commit is contained in:
Vadim Zeitlin
2021-07-10 13:03:46 +01:00
parent 07e80803da
commit cd8fea8056

View File

@@ -3772,13 +3772,12 @@ wxWindowMSW::MSWHandleMessage(WXLRESULT *result,
// it below if it fails.
RECT rcClient;
wxClientDC dc((wxWindow *)this);
wxMSWDCImpl *impl = (wxMSWDCImpl*) dc.GetImpl();
WindowHDC hdc(GetHwnd());
if ( ::GetThemeBackgroundContentRect
(
hTheme,
GetHdcOf(*impl),
hdc,
EP_EDITTEXT,
IsEnabled() ? ETS_NORMAL : ETS_DISABLED,
rect,