From 7572015bda1591b1d1ec7d3b283e4bc0708ef0ee Mon Sep 17 00:00:00 2001 From: Christophe Meriaux Date: Mon, 12 Feb 2018 23:44:52 +0100 Subject: [PATCH] Enhance ShortcutMapper resizing - keep centered buttons while resizing - set minimum width and height Close #4178 --- .../src/WinControls/Grid/ShortcutMapper.cpp | 18 +++++++++++++++++- .../src/WinControls/Grid/ShortcutMapper.h | 4 ++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/PowerEditor/src/WinControls/Grid/ShortcutMapper.cpp b/PowerEditor/src/WinControls/Grid/ShortcutMapper.cpp index a55e8227..21d20478 100644 --- a/PowerEditor/src/WinControls/Grid/ShortcutMapper.cpp +++ b/PowerEditor/src/WinControls/Grid/ShortcutMapper.cpp @@ -425,8 +425,24 @@ INT_PTR CALLBACK ShortcutMapper::run_dlgProc(UINT message, WPARAM wParam, LPARAM _clientWidth = rect.right - rect.left; _clientHeight = rect.bottom - rect.top; + int cy_border = GetSystemMetrics(SM_CYFRAME); + int cy_caption = GetSystemMetrics(SM_CYCAPTION); + _initClientWidth = _clientWidth; + _initClientHeight = _clientHeight + cy_caption + cy_border; + _dialogInitDone = true; + return TRUE; } + case WM_GETMINMAXINFO : + { + MINMAXINFO* mmi = (MINMAXINFO*)lParam; + if (_dialogInitDone) + { + mmi->ptMinTrackSize.x = _initClientWidth; + mmi->ptMinTrackSize.y = _initClientHeight; + } + return 0; + } case WM_DESTROY: { @@ -464,7 +480,7 @@ INT_PTR CALLBACK ShortcutMapper::run_dlgProc(UINT message, WPARAM wParam, LPARAM HWND moveHwnd = ::GetDlgItem(_hSelf, moveWndID); ::GetWindowRect(moveHwnd, &rect); ::MapWindowPoints(NULL, _hSelf, (LPPOINT)&rect, 2); - ::SetWindowPos(moveHwnd, NULL, rect.left + addWidth, rect.top + addHeight, 0, 0, SWP_NOSIZE | flags); + ::SetWindowPos(moveHwnd, NULL, rect.left + addWidth / 2, rect.top + addHeight, 0, 0, SWP_NOSIZE | flags); } HWND moveHwnd = ::GetDlgItem(_hSelf, IDC_BABYGRID_STATIC); ::GetWindowRect(moveHwnd, &rect); diff --git a/PowerEditor/src/WinControls/Grid/ShortcutMapper.h b/PowerEditor/src/WinControls/Grid/ShortcutMapper.h index 0f23071a..749eebd4 100644 --- a/PowerEditor/src/WinControls/Grid/ShortcutMapper.h +++ b/PowerEditor/src/WinControls/Grid/ShortcutMapper.h @@ -39,6 +39,7 @@ class ShortcutMapper : public StaticDialog { public: ShortcutMapper() : _currentState(STATE_MENU), StaticDialog() { _shortcutFilter = TEXT(""); + _dialogInitDone = false; }; ~ShortcutMapper() {}; @@ -100,6 +101,9 @@ private: }; LONG _clientWidth; LONG _clientHeight; + LONG _initClientWidth; + LONG _initClientHeight; + bool _dialogInitDone; void initTabs(); void initBabyGrid();