From 934c9888742510d75d3830c4151394fa0e0b1f0c Mon Sep 17 00:00:00 2001 From: Don Ho Date: Mon, 26 Jul 2021 23:55:35 +0200 Subject: [PATCH] Make Shortcut mapper display correctly under high DPI --- .../src/WinControls/Grid/ShortcutMapper.cpp | 18 ++++++++++++++++-- .../src/WinControls/Grid/ShortcutMapper.rc | 6 +++--- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/PowerEditor/src/WinControls/Grid/ShortcutMapper.cpp b/PowerEditor/src/WinControls/Grid/ShortcutMapper.cpp index 0f59a7658..be234bc57 100644 --- a/PowerEditor/src/WinControls/Grid/ShortcutMapper.cpp +++ b/PowerEditor/src/WinControls/Grid/ShortcutMapper.cpp @@ -55,8 +55,22 @@ void ShortcutMapper::getClientRect(RECT & rc) const { Window::getClientRect(rc); - rc.top += NppParameters::getInstance()._dpiManager.scaleY(30); - rc.bottom -= NppParameters::getInstance()._dpiManager.scaleY(108); + RECT tabRect, btnRect; + ::GetClientRect(::GetDlgItem(_hSelf, IDC_BABYGRID_TABBAR), &tabRect); + int tabH = tabRect.bottom - tabRect.top; + int paddingTop = tabH / 2; + rc.top += tabH + paddingTop; + + RECT infoRect, filterRect; + ::GetClientRect(::GetDlgItem(_hSelf, IDC_BABYGRID_INFO), &infoRect); + ::GetClientRect(::GetDlgItem(_hSelf, IDC_BABYGRID_FILTER), &filterRect); + ::GetClientRect(::GetDlgItem(_hSelf, IDOK), &btnRect); + int infoH = infoRect.bottom - infoRect.top; + int filterH = filterRect.bottom - filterRect.top; + int btnH = btnRect.bottom - btnRect.top; + int paddingBottom = btnH; + rc.bottom -= btnH + filterH + infoH + paddingBottom; + rc.left += NppParameters::getInstance()._dpiManager.scaleX(5); rc.right -= NppParameters::getInstance()._dpiManager.scaleX(5); } diff --git a/PowerEditor/src/WinControls/Grid/ShortcutMapper.rc b/PowerEditor/src/WinControls/Grid/ShortcutMapper.rc index 215380930..288d255a3 100755 --- a/PowerEditor/src/WinControls/Grid/ShortcutMapper.rc +++ b/PowerEditor/src/WinControls/Grid/ShortcutMapper.rc @@ -29,11 +29,11 @@ CAPTION "Shortcut mapper" FONT 8, TEXT("MS Shell Dlg"), 400, 0, 0x1 BEGIN CONTROL "",IDC_BABYGRID_TABBAR,"SysTabControl32",WS_TABSTOP,4,6,384,12 + EDITTEXT IDC_BABYGRID_INFO, 4, 281, 440, 29, ES_MULTILINE | ES_AUTOHSCROLL | ES_READONLY | WS_VSCROLL | NOT WS_TABSTOP + RTEXT "Filter :", IDC_BABYGRID_STATIC, 4, 313, 25, 12 + EDITTEXT IDC_BABYGRID_FILTER, 30, 312, 415, 12, ES_AUTOHSCROLL | ES_WANTRETURN | NOT WS_BORDER, WS_EX_STATICEDGE DEFPUSHBUTTON "Modify",IDM_BABYGRID_MODIFY,118,330,47,14 DEFPUSHBUTTON "Clear",IDM_BABYGRID_CLEAR,172,330,47,14 DEFPUSHBUTTON "Delete",IDM_BABYGRID_DELETE,226,330,47,14 DEFPUSHBUTTON "Close",IDOK,280,330,47,14 - EDITTEXT IDC_BABYGRID_INFO,4,281,440,29,ES_MULTILINE | ES_AUTOHSCROLL | ES_READONLY | WS_VSCROLL | NOT WS_TABSTOP - RTEXT "Filter :",IDC_BABYGRID_STATIC,4,313,25,12 - EDITTEXT IDC_BABYGRID_FILTER,30,312,415,12,ES_AUTOHSCROLL | ES_WANTRETURN | NOT WS_BORDER,WS_EX_STATICEDGE END