From 75ee0becd1e57a1c0d6c92394268a455d49dc35b Mon Sep 17 00:00:00 2001 From: Leland Lucius Date: Mon, 24 Aug 2015 23:46:04 -0500 Subject: [PATCH] Allow the user to make the FileDialog smaller after enlarging it. See http://bugzilla.audacityteam.org/show_bug.cgi?id=1110#c6 for a bit more info. --- lib-src/FileDialog/win/FileDialogPrivate.cpp | 34 ++++++++++++++++++++ lib-src/FileDialog/win/FileDialogPrivate.h | 2 ++ 2 files changed, 36 insertions(+) diff --git a/lib-src/FileDialog/win/FileDialogPrivate.cpp b/lib-src/FileDialog/win/FileDialogPrivate.cpp index 709a899bb..64db7c062 100644 --- a/lib-src/FileDialog/win/FileDialogPrivate.cpp +++ b/lib-src/FileDialog/win/FileDialogPrivate.cpp @@ -170,6 +170,11 @@ UINT_PTR FileDialog::MSWParentHook(HWND hDlg, UINT iMsg, WPARAM wParam, LPARAM l MSWOnSize(mParentDlg, pOfn); } + if (iMsg == WM_GETMINMAXINFO) + { + MSWOnGetMinMaxInfo(mParentDlg, pOfn, reinterpret_cast(lParam)); + } + return ret; } @@ -198,6 +203,35 @@ void FileDialog::MSWOnSize(HWND hDlg, LPOPENFILENAME pOfn) SetHWND(NULL); } +// Capture the minimum dialog size by saving the first non-zero size. +// +// We get called multiple times: +// +// The first, ptMinTrackSize will be {0, 0}. +// +// The second, ptMinTrackSize will be the absolute minimum to contain all controls. This is +// the POINT we will use to override the subsequent calls. +// +// Additional calls are made when the user resizes the dialog and for some unknown reason the +// the common dialog control doesn't let the user resize the dialog smaller than it was the +// last time the dialog was used. This information is kept in: +// +// HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\ComDlg32\CIDSizeMRU +// +// So, we override the minimum size supplied by the common dialog control with the captured +// size from the second call. +void FileDialog::MSWOnGetMinMaxInfo(HWND hwnd, LPOPENFILENAME pOfn, LPMINMAXINFO pMmi) +{ + if (mMinSize.x > 0 && mMinSize.y > 0) + { + pMmi->ptMinTrackSize = mMinSize; + } + else + { + mMinSize = pMmi->ptMinTrackSize; + } +} + UINT_PTR APIENTRY FileDialog::DialogHook(HWND hDlg, UINT iMsg, WPARAM wParam, LPARAM lParam) { OPENFILENAME *pOfn; diff --git a/lib-src/FileDialog/win/FileDialogPrivate.h b/lib-src/FileDialog/win/FileDialogPrivate.h index 21822c4b2..aab728bb2 100644 --- a/lib-src/FileDialog/win/FileDialogPrivate.h +++ b/lib-src/FileDialog/win/FileDialogPrivate.h @@ -64,6 +64,7 @@ private: // Message handlers for the parent dialog virtual void MSWOnSize(HWND hwnd, LPOPENFILENAME pOfn); + virtual void MSWOnGetMinMaxInfo(HWND hwnd, LPOPENFILENAME pOfn, LPMINMAXINFO pMmi); // Child dialog hook static UINT_PTR APIENTRY DialogHook(HWND hDlg, UINT iMsg, WPARAM wParam, LPARAM lParam); @@ -93,6 +94,7 @@ private: HWND mParentDlg; HWND mChildDlg; WNDPROC mParentProc; + POINT mMinSize; wxPanel *mRoot;