From 220f77b0d2ab5943eb7ab90c3072b828717ce66e Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 4 Jan 2005 18:57:41 +0000 Subject: [PATCH] restored using DeferWindowPos() for moving all windows at once (this does help with flicker somewhat) but now call EndDeferWindowPos() from WM_WINDOWPOSCHANGED handler, not WM_SIZE one which is never generated for the dialogs git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@31232 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/msw/window.h | 4 +++ src/msw/window.cpp | 65 +++++++++++++++++++++++++++++++++++++++-- 2 files changed, 67 insertions(+), 2 deletions(-) diff --git a/include/wx/msw/window.h b/include/wx/msw/window.h index a4ce110bc6..63fb987784 100644 --- a/include/wx/msw/window.h +++ b/include/wx/msw/window.h @@ -493,6 +493,10 @@ private: // number of calls to Freeze() minus number of calls to Thaw() unsigned int m_frozenness; + // current defer window position operation handle (may be NULL) + HANDLE m_hDWP; + + DECLARE_DYNAMIC_CLASS(wxWindowMSW) DECLARE_NO_COPY_CLASS(wxWindowMSW) DECLARE_EVENT_TABLE() diff --git a/src/msw/window.cpp b/src/msw/window.cpp index 1331e0e476..0fdbdbacca 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -437,6 +437,7 @@ void wxWindowMSW::Init() m_frozenness = 0; m_hWnd = 0; + m_hDWP = 0; m_xThumbSize = 0; m_yThumbSize = 0; @@ -1531,9 +1532,29 @@ void wxWindowMSW::DoMoveWindow(int x, int y, int width, int height) if (height < 0) height = 0; - if ( !::MoveWindow(GetHwnd(), x, y, width, height, TRUE) ) + // if our parent had prepared a defer window handle for us, use it + HDWP hdwp = m_parent ? (HDWP)m_parent->m_hDWP : NULL; + if ( hdwp ) { - wxLogLastError(wxT("MoveWindow")); + hdwp = ::DeferWindowPos(hdwp, GetHwnd(), NULL, + x, y, width, height, + SWP_NOZORDER); + if ( !hdwp ) + { + wxLogLastError(_T("DeferWindowPos")); + } + + // hdwp must be updated as it may have been changed + m_parent->m_hDWP = (WXHANDLE)hdwp; + } + + // otherwise (or if deferring failed) move the window in place immediately + if ( !hdwp ) + { + if ( !::MoveWindow(GetHwnd(), x, y, width, height, TRUE) ) + { + wxLogLastError(wxT("MoveWindow")); + } } } @@ -2240,6 +2261,46 @@ WXLRESULT wxWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM l (void)HandleDestroy(); break; + case WM_WINDOWPOSCHANGING: + { + WINDOWPOS *wp = wx_reinterpret_cast(WINDOWPOS *, lParam); + + if ( wp->flags & SWP_NOSIZE ) + break; + + // when we resize this window, its children are probably going + // to be repositioned as well, prepare to use DeferWindowPos() + // for them + const int numChildren = GetChildren().GetCount(); + if ( numChildren > 1 ) + { + m_hDWP = (WXHANDLE)::BeginDeferWindowPos(numChildren); + if ( !m_hDWP ) + { + wxLogLastError(_T("BeginDeferWindowPos")); + } + } + } + break; + + case WM_WINDOWPOSCHANGED: + // first let DefWindowProc() handle the message: it will generate + // WM_MOVE and WM_SIZE as needed + processed = MSWDefWindowProc(message, wParam, lParam) == 0; + + // then change the positions of all child windows at once + if ( m_hDWP ) + { + // put all child controls in place at once now + if ( !::EndDeferWindowPos((HDWP)m_hDWP) ) + { + wxLogLastError(_T("EndDeferWindowPos")); + } + + m_hDWP = NULL; + } + break; + case WM_SIZE: processed = HandleSize(LOWORD(lParam), HIWORD(lParam), wParam); break; -- 2.45.2