From cd8fea805603959d0c337948eab68ea27ef5a2ea Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 10 Jul 2021 13:03:46 +0100 Subject: [PATCH] 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. --- src/msw/window.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/msw/window.cpp b/src/msw/window.cpp index 93deabd818..e869d58539 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -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,