+// ----------------------------------------------------------------------------
+// wxDialog gripper handling
+// ----------------------------------------------------------------------------
+
+void wxDialog::SetWindowStyleFlag(long style)
+{
+ wxDialogBase::SetWindowStyleFlag(style);
+
+ if ( HasFlag(wxRESIZE_BORDER) )
+ CreateGripper();
+ else
+ DestroyGripper();
+}
+
+void wxDialog::CreateGripper()
+{
+ if ( !m_hGripper )
+ {
+ // just create it here, it will be positioned and shown later
+ m_hGripper = (WXHWND)::CreateWindow
+ (
+ wxT("SCROLLBAR"),
+ wxT(""),
+ WS_CHILD |
+ WS_CLIPSIBLINGS |
+ SBS_SIZEGRIP |
+ SBS_SIZEBOX |
+ SBS_SIZEBOXBOTTOMRIGHTALIGN,
+ 0, 0, 0, 0,
+ GetHwnd(),
+ 0,
+ wxGetInstance(),
+ NULL
+ );
+ }
+}
+
+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;
+ }
+}
+
+void wxDialog::ShowGripper(bool show)
+{
+ wxASSERT_MSG( m_hGripper, _T("shouldn't be called if we have no gripper") );
+
+ if ( show )
+ ResizeGripper();
+
+ ::ShowWindow((HWND)m_hGripper, show ? SW_SHOW : SW_HIDE);
+}
+
+void wxDialog::ResizeGripper()
+{
+ wxASSERT_MSG( m_hGripper, _T("shouldn't be called if we have no gripper") );
+
+ HWND hwndGripper = (HWND)m_hGripper;
+
+ const wxRect rectGripper = wxRectFromRECT(wxGetWindowRect(hwndGripper));
+ const wxSize size = GetClientSize() - rectGripper.GetSize();
+
+ ::SetWindowPos(hwndGripper, HWND_BOTTOM,
+ size.x, size.y,
+ rectGripper.width, rectGripper.height,
+ 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();
+}
+