Code enhancement: Use dlg resource parameters instead of reSizeTo

Fix #12857, close #12858
pull/13027/head
ozone10 2022-12-30 21:12:58 +01:00 committed by Don Ho
parent 409c363e1a
commit e003f5b45f
3 changed files with 25 additions and 52 deletions

View File

@ -19,7 +19,7 @@
#include "regExtDlgRc.h" #include "regExtDlgRc.h"
IDD_REGEXT_BOX DIALOGEX 0, 0, 370, 180 IDD_REGEXT_BOX DIALOGEX 115, 10, 460, 205
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | DS_CONTROL STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | DS_CONTROL
FONT 8, TEXT("MS Shell Dlg"), 0, 0, 0x1 FONT 8, TEXT("MS Shell Dlg"), 0, 0, 0x1
BEGIN BEGIN

View File

@ -29,12 +29,12 @@ EXSTYLE WS_EX_DLGMODALFRAME | WS_EX_WINDOWEDGE
CAPTION "Preferences" CAPTION "Preferences"
FONT 8, "MS Shell Dlg", 0, 0, 0x1 FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN BEGIN
LISTBOX IDC_LIST_DLGTITLE,10,10,100,203,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_HSCROLL | WS_TABSTOP LISTBOX IDC_LIST_DLGTITLE,10,10,100,215,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_HSCROLL | WS_TABSTOP
PUSHBUTTON "Close",IDC_BUTTON_CLOSE,255,215,45,14 PUSHBUTTON "Close",IDC_BUTTON_CLOSE,320,215,50,14
END END
IDD_PREFERENCE_SUB_GENRAL DIALOGEX 0, 0, 455, 203 IDD_PREFERENCE_SUB_GENRAL DIALOGEX 115, 10, 460, 205
STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
FONT 8, "MS Shell Dlg", 0, 0, 0x1 FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN BEGIN
@ -66,7 +66,7 @@ BEGIN
END END
IDD_PREFERENCE_SUB_EDITING DIALOGEX 0, 0, 455, 203 IDD_PREFERENCE_SUB_EDITING DIALOGEX 115, 10, 460, 205
STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
FONT 8, "MS Shell Dlg", 0, 0, 0x1 FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN BEGIN
@ -103,7 +103,7 @@ BEGIN
END END
IDD_PREFERENCE_SUB_DARKMODE DIALOGEX 0, 0, 455, 185 IDD_PREFERENCE_SUB_DARKMODE DIALOGEX 115, 10, 460, 205
STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
FONT 8, "MS Shell Dlg", 0, 0, 0x1 FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN BEGIN
@ -134,7 +134,7 @@ BEGIN
PUSHBUTTON "Reset",IDD_CUSTOMIZED_RESET_BUTTON,340,158,45,14 PUSHBUTTON "Reset",IDD_CUSTOMIZED_RESET_BUTTON,340,158,45,14
END END
IDD_PREFERENCE_SUB_MARGING_BORDER_EDGE DIALOGEX 0, 0, 455, 185 IDD_PREFERENCE_SUB_MARGING_BORDER_EDGE DIALOGEX 115, 10, 460, 205
STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
FONT 8, "MS Shell Dlg", 0, 0, 0x1 FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN BEGIN
@ -172,7 +172,7 @@ END
IDD_PREFERENCE_SUB_NEWDOCUMENT DIALOGEX 0, 0, 455, 185 IDD_PREFERENCE_SUB_NEWDOCUMENT DIALOGEX 115, 10, 460, 205
STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
FONT 8, "MS Shell Dlg", 0, 0, 0x1 FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN BEGIN
@ -195,7 +195,7 @@ BEGIN
END END
IDD_PREFERENCE_SUB_DEFAULTDIRECTORY DIALOGEX 0, 0, 455, 185 IDD_PREFERENCE_SUB_DEFAULTDIRECTORY DIALOGEX 115, 10, 460, 205
STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
FONT 8, "MS Shell Dlg", 0, 0, 0x1 FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN BEGIN
@ -209,7 +209,7 @@ BEGIN
END END
IDD_PREFERENCE_SUB_RECENTFILESHISTORY DIALOGEX 0, 0, 455, 185 IDD_PREFERENCE_SUB_RECENTFILESHISTORY DIALOGEX 115, 10, 460, 205
STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
FONT 8, "MS Shell Dlg", 0, 0, 0x1 FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN BEGIN
@ -226,7 +226,7 @@ BEGIN
END END
IDD_PREFERENCE_SUB_LANGUAGE DIALOGEX 0, 0, 455, 185 IDD_PREFERENCE_SUB_LANGUAGE DIALOGEX 115, 10, 460, 205
STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
FONT 8, "MS Shell Dlg", 0, 0, 0x1 FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN BEGIN
@ -250,7 +250,7 @@ BEGIN
END END
IDD_PREFERENCE_SUB_HIGHLIGHTING DIALOGEX 0, 0, 455, 185 IDD_PREFERENCE_SUB_HIGHLIGHTING DIALOGEX 115, 10, 460, 205
STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
FONT 8, "MS Shell Dlg", 0, 0, 0x1 FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN BEGIN
@ -271,7 +271,7 @@ BEGIN
END END
IDD_PREFERENCE_SUB_PRINT DIALOGEX 0, 0, 455, 185 IDD_PREFERENCE_SUB_PRINT DIALOGEX 115, 10, 460, 205
STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
FONT 8, "MS Shell Dlg", 0, 0, 0x1 FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN BEGIN
@ -321,7 +321,7 @@ BEGIN
END END
IDD_PREFERENCE_SUB_SEARCHING DIALOGEX 0, 0, 455, 185 IDD_PREFERENCE_SUB_SEARCHING DIALOGEX 115, 10, 460, 205
STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
FONT 8, "MS Shell Dlg", 0, 0, 0x1 FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN BEGIN
@ -336,7 +336,7 @@ BEGIN
END END
IDD_PREFERENCE_SUB_BACKUP DIALOGEX 0, 0, 455, 185 IDD_PREFERENCE_SUB_BACKUP DIALOGEX 115, 10, 460, 205
STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
FONT 8, "MS Shell Dlg", 0, 0, 0x1 FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN BEGIN
@ -360,7 +360,7 @@ BEGIN
END END
IDD_PREFERENCE_SUB_AUTOCOMPLETION DIALOGEX 0, 0, 455, 185 IDD_PREFERENCE_SUB_AUTOCOMPLETION DIALOGEX 115, 10, 460, 205
STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
FONT 8, "MS Shell Dlg", 0, 0, 0x1 FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN BEGIN
@ -432,7 +432,7 @@ BEGIN
END END
IDD_PREFERENCE_SUB_DELIMITER DIALOGEX 0, 0, 455, 185 IDD_PREFERENCE_SUB_DELIMITER DIALOGEX 115, 10, 460, 205
STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
FONT 8, "MS Shell Dlg", 0, 0, 0x1 FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN BEGIN
@ -454,7 +454,7 @@ BEGIN
END END
IDD_PREFERENCE_SUB_CLOUD_LINK DIALOGEX 0, 0, 455, 185 IDD_PREFERENCE_SUB_CLOUD_LINK DIALOGEX 115, 10, 460, 205
STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
FONT 8, "MS Shell Dlg", 0, 0, 0x1 FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN BEGIN
@ -474,7 +474,7 @@ BEGIN
END END
IDD_PREFERENCE_SUB_SEARCHENGINE DIALOGEX 0, 0, 455, 185 IDD_PREFERENCE_SUB_SEARCHENGINE DIALOGEX 115, 10, 460, 205
STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
FONT 8, "MS Shell Dlg", 0, 0, 0x1 FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN BEGIN
@ -488,7 +488,7 @@ BEGIN
LTEXT "Example: https://www.google.com/search?q=$(CURRENT_WORD)",IDD_SEARCHENGINE_NOTE_STATIC,114,134,245,20 LTEXT "Example: https://www.google.com/search?q=$(CURRENT_WORD)",IDD_SEARCHENGINE_NOTE_STATIC,114,134,245,20
END END
IDD_PREFERENCE_SUB_PERFORMANCE DIALOGEX 0, 0, 455, 185 IDD_PREFERENCE_SUB_PERFORMANCE DIALOGEX 115, 10, 460, 205
STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
FONT 8, "MS Shell Dlg", 0, 0, 0x1 FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN BEGIN
@ -505,7 +505,7 @@ BEGIN
CONTROL "Allow URL Clickable Link", IDC_CHECK_PERFORMANCE_ALLOWCLICKABLELINK, "Button", BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP, 127, 140, 200, 10 CONTROL "Allow URL Clickable Link", IDC_CHECK_PERFORMANCE_ALLOWCLICKABLELINK, "Button", BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP, 127, 140, 200, 10
END END
IDD_PREFERENCE_SUB_MISC DIALOGEX 0, 0, 455, 200 IDD_PREFERENCE_SUB_MISC DIALOGEX 115, 10, 460, 205
STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
FONT 8, "MS Shell Dlg", 0, 0, 0x1 FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN BEGIN

View File

@ -199,33 +199,6 @@ intptr_t CALLBACK PreferenceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM
makeCategoryList(); makeCategoryList();
RECT rc;
getClientRect(rc);
rc.top += NppParameters::getInstance()._dpiManager.scaleY(10);
rc.bottom -= NppParameters::getInstance()._dpiManager.scaleY(50);
rc.left += NppParameters::getInstance()._dpiManager.scaleX(170);
_generalSubDlg.reSizeTo(rc);
_editingSubDlg.reSizeTo(rc);
_darkModeSubDlg.reSizeTo(rc);
_marginsBorderEdgeSubDlg.reSizeTo(rc);
_miscSubDlg.reSizeTo(rc);
_newDocumentSubDlg.reSizeTo(rc);
_defaultDirectorySubDlg.reSizeTo(rc);
_recentFilesHistorySubDlg.reSizeTo(rc);
_fileAssocDlg.reSizeTo(rc);
_languageSubDlg.reSizeTo(rc);
_highlightingSubDlg.reSizeTo(rc);
_printSubDlg.reSizeTo(rc);
_searchingSubDlg.reSizeTo(rc);
_backupSubDlg.reSizeTo(rc);
_autoCompletionSubDlg.reSizeTo(rc);
_multiInstanceSubDlg.reSizeTo(rc);
_delimiterSubDlg.reSizeTo(rc);
_performanceSubDlg.reSizeTo(rc);
_cloudAndLinkSubDlg.reSizeTo(rc);
_searchEngineSubDlg.reSizeTo(rc);
NppDarkMode::autoSubclassAndThemeChildControls(_hSelf); NppDarkMode::autoSubclassAndThemeChildControls(_hSelf);
@ -421,7 +394,7 @@ bool PreferenceDlg::setListSelection(size_t currentSel) const
{ {
// Stupid LB API doesn't allow LB_SETSEL to be used on single select listbox, so we do it in a hard way // Stupid LB API doesn't allow LB_SETSEL to be used on single select listbox, so we do it in a hard way
const size_t selStrLenMax = 255; const size_t selStrLenMax = 255;
TCHAR selStr[selStrLenMax + 1]; TCHAR selStr[selStrLenMax + 1] = { '\0' };
auto lbTextLen = ::SendMessage(_hSelf, LB_GETTEXTLEN, currentSel, 0); auto lbTextLen = ::SendMessage(_hSelf, LB_GETTEXTLEN, currentSel, 0);
if (static_cast<size_t>(lbTextLen) > selStrLenMax) if (static_cast<size_t>(lbTextLen) > selStrLenMax)
@ -764,7 +737,7 @@ intptr_t CALLBACK GeneralSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM
{ {
LocalizationSwitcher & localizationSwitcher = nppParam.getLocalizationSwitcher(); LocalizationSwitcher & localizationSwitcher = nppParam.getLocalizationSwitcher();
auto index = ::SendDlgItemMessage(_hSelf, IDC_COMBO_LOCALIZATION, CB_GETCURSEL, 0, 0); auto index = ::SendDlgItemMessage(_hSelf, IDC_COMBO_LOCALIZATION, CB_GETCURSEL, 0, 0);
TCHAR langName[MAX_PATH]; TCHAR langName[MAX_PATH] = { '\0' };
auto cbTextLen = ::SendDlgItemMessage(_hSelf, IDC_COMBO_LOCALIZATION, CB_GETLBTEXTLEN, index, 0); auto cbTextLen = ::SendDlgItemMessage(_hSelf, IDC_COMBO_LOCALIZATION, CB_GETLBTEXTLEN, index, 0);
if (cbTextLen > MAX_PATH - 1) if (cbTextLen > MAX_PATH - 1)
return TRUE; return TRUE;
@ -1186,8 +1159,8 @@ void DarkModeSubDlg::enableCustomizedColorCtrls(bool doEnable)
void DarkModeSubDlg::move2CtrlLeft(int ctrlID, HWND handle2Move, int handle2MoveWidth, int handle2MoveHeight) void DarkModeSubDlg::move2CtrlLeft(int ctrlID, HWND handle2Move, int handle2MoveWidth, int handle2MoveHeight)
{ {
POINT p; POINT p{};
RECT rc; RECT rc{};
::GetWindowRect(::GetDlgItem(_hSelf, ctrlID), &rc); ::GetWindowRect(::GetDlgItem(_hSelf, ctrlID), &rc);
NppParameters& nppParam = NppParameters::getInstance(); NppParameters& nppParam = NppParameters::getInstance();