From 2c66581eaae92045864aa8d0ab80fc27f8725e52 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 11 May 2008 17:12:36 +0000 Subject: [PATCH] show resize grip on resizeable dialogs (slightly modified patch 1910654) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@53554 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 1 + include/wx/msw/dialog.h | 12 ++++++ src/msw/dialog.cpp | 92 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 105 insertions(+) diff --git a/docs/changes.txt b/docs/changes.txt index 035f9af941..2c01c0deb9 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -353,6 +353,7 @@ wxMSW: - Allow tooltips longer than 64 (up to 128) characters in wxTaskBarIcon - Fix centering wxFileDialog and allow positioning it - Allow centering wxMessageDialog on its parent window (troelsk) +- Show resize gripper on resizeable dialogs (Kolya Kosenko) - Implement support for display enumeration under WinCE (Vince Harron) - Use different Win32 class names in different wx instances (Thomas Hauk) diff --git a/include/wx/msw/dialog.h b/include/wx/msw/dialog.h index e29a5e045f..cf91c11961 100644 --- a/include/wx/msw/dialog.h +++ b/include/wx/msw/dialog.h @@ -85,6 +85,8 @@ public: virtual void Raise(); + virtual void SetWindowStyleFlag(long style); + #ifdef __POCKETPC__ // Responds to the OK button in a PocketPC titlebar. This // can be overridden, or you can change the id used for @@ -106,6 +108,13 @@ protected: // common part of all ctors void Init(); + // these functions deal with the gripper window shown in the corner of + // resizeable dialogs + void CreateGripper(); + void DestroyGripper(); + void ShowGripper(bool show); + void ResizeGripper(); + private: wxWindow* m_oldFocus; bool m_endModalCalled; // allow for closing within InitDialog @@ -117,6 +126,9 @@ private: // this pointer is non-NULL only while the modal event loop is running wxDialogModalData *m_modalData; + // gripper window for a resizable dialog, NULL if we're not resizable + WXHWND m_hGripper; + DECLARE_DYNAMIC_CLASS(wxDialog) DECLARE_NO_COPY_CLASS(wxDialog) }; diff --git a/src/msw/dialog.cpp b/src/msw/dialog.cpp index 4fce3f8d47..64d7f61bc6 100644 --- a/src/msw/dialog.cpp +++ b/src/msw/dialog.cpp @@ -152,6 +152,7 @@ void wxDialog::Init() #if wxUSE_TOOLBAR && defined(__POCKETPC__) m_dialogToolBar = NULL; #endif + m_hGripper = 0; } bool wxDialog::Create(wxWindow *parent, @@ -183,6 +184,9 @@ bool wxDialog::Create(wxWindow *parent, CreateToolBar(); #endif + if( HasFlag(wxRESIZE_BORDER) ) + CreateGripper(); + return true; } @@ -192,6 +196,8 @@ wxDialog::~wxDialog() // this will also reenable all the other windows for a modal dialog Show(false); + + DestroyGripper(); } // ---------------------------------------------------------------------------- @@ -335,6 +341,75 @@ void wxDialog::EndModal(int retCode) Hide(); } +// ---------------------------------------------------------------------------- +// wxDialog gripper handling +// ---------------------------------------------------------------------------- + +void wxDialog::SetWindowStyleFlag(long style) +{ + wxDialogBase::SetWindowStyleFlag(style); + + if( HasFlag(wxRESIZE_BORDER) ) + CreateGripper(); + else + DestroyGripper(); +} + +void wxDialog::CreateGripper() +{ + if( !m_hGripper ) + { + m_hGripper = (WXHWND)::CreateWindow + ( + wxT("SCROLLBAR"), + wxT(""), + WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | + SBS_SIZEGRIP | + SBS_SIZEBOX | + SBS_SIZEBOXBOTTOMRIGHTALIGN, + 0, 0, 0, 0, + GetHwnd(), + 0, + wxGetInstance(), + NULL + ); + + // position the gripper correctly after creation + ResizeGripper(); + } +} + +void wxDialog::DestroyGripper() +{ + if ( m_hGripper ) + { + ::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") ); + + ::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); +} + // ---------------------------------------------------------------------------- // wxWin event handlers // ---------------------------------------------------------------------------- @@ -416,6 +491,23 @@ WXLRESULT wxDialog::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lPar break; case WM_SIZE: + if ( m_hGripper ) + { + switch ( wParam ) + { + case SIZE_MAXIMIZED: + ShowGripper(false); + break; + + case SIZE_RESTORED: + ShowGripper(true); + // fall through + + default: + ResizeGripper(); + } + } + // the Windows dialogs unfortunately are not meant to be resizeable // at all and their standard class doesn't include CS_[VH]REDRAW // styles which means that the window is not refreshed properly -- 2.47.2