From: Vadim Zeitlin Date: Sat, 7 Jun 2008 02:04:16 +0000 (+0000) Subject: ensure that dialog gripper is always positioned below the other children, even if... X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/eddc468e258b0824a230a6a8e844a98234cb8da4?ds=inline ensure that dialog gripper is always positioned below the other children, even if they're created after it (#9519) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@54009 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/msw/dialog.h b/include/wx/msw/dialog.h index cf91c11961..c9da9e53d2 100644 --- a/include/wx/msw/dialog.h +++ b/include/wx/msw/dialog.h @@ -116,6 +116,11 @@ protected: void ResizeGripper(); private: + // this function is used to adjust Z-order of new children relative to the + // gripper if we have one + void OnWindowCreate(wxWindowCreateEvent& event); + + wxWindow* m_oldFocus; bool m_endModalCalled; // allow for closing within InitDialog diff --git a/src/msw/dialog.cpp b/src/msw/dialog.cpp index d89e8ede2c..9d28a6e039 100644 --- a/src/msw/dialog.cpp +++ b/src/msw/dialog.cpp @@ -185,8 +185,13 @@ bool wxDialog::Create(wxWindow *parent, #endif if ( HasFlag(wxRESIZE_BORDER) ) + { CreateGripper(); + Connect(wxEVT_CREATE, + wxWindowCreateEventHandler(wxDialog::OnWindowCreate)); + } + return true; } @@ -384,6 +389,11 @@ void wxDialog::DestroyGripper() { if ( m_hGripper ) { + // we used to have trouble with gripper appearing on top (and hence + // overdrawing) the other, real, dialog children -- check that this + // isn't the case automatically + wxASSERT_MSG( ::GetNextWindow((HWND)m_hGripper, GW_HWNDNEXT) == 0, + _T("Bug in wxWidgets: gripper should be at the bottom of Z-order") ); ::DestroyWindow((HWND) m_hGripper); m_hGripper = 0; } @@ -414,6 +424,19 @@ void wxDialog::ResizeGripper() SWP_NOACTIVATE); } +void wxDialog::OnWindowCreate(wxWindowCreateEvent& event) +{ + if ( m_hGripper && IsShown() && + event.GetWindow() && event.GetWindow()->GetParent() == this ) + { + // Put gripper below the newly created child window + ::SetWindowPos((HWND)m_hGripper, HWND_BOTTOM, 0, 0, 0, 0, + SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE); + } + + event.Skip(); +} + // ---------------------------------------------------------------------------- // wxWin event handlers // ----------------------------------------------------------------------------