From 3cf45ec3a86cf19546b8b1f3934ae9617b7b9d7c Mon Sep 17 00:00:00 2001 From: ozone10 Date: Sun, 16 Apr 2023 10:34:19 +0200 Subject: [PATCH] Reorder tab focus in Run dlg Plus: - add key accelerators. - remove unneeded library. - add initializers. Fix #13540, close #13541 --- .../StaticDialog/RunDlg/RunDlg.cpp | 48 +++++++++---------- .../WinControls/StaticDialog/RunDlg/RunDlg.h | 5 +- .../WinControls/StaticDialog/RunDlg/RunDlg.rc | 18 ++++--- PowerEditor/visual.net/notepadPlus.Cpp.props | 2 +- 4 files changed, 33 insertions(+), 40 deletions(-) diff --git a/PowerEditor/src/WinControls/StaticDialog/RunDlg/RunDlg.cpp b/PowerEditor/src/WinControls/StaticDialog/RunDlg/RunDlg.cpp index 42a18257a..4778d66e3 100644 --- a/PowerEditor/src/WinControls/StaticDialog/RunDlg/RunDlg.cpp +++ b/PowerEditor/src/WinControls/StaticDialog/RunDlg/RunDlg.cpp @@ -187,15 +187,15 @@ HINSTANCE Command::run(HWND hWnd) HINSTANCE Command::run(HWND hWnd, const TCHAR* cwd) { - const int argsIntermediateLen = MAX_PATH*2; - const int args2ExecLen = CURRENTWORD_MAXLENGTH+MAX_PATH*2; + constexpr int argsIntermediateLen = MAX_PATH * 2; + constexpr int args2ExecLen = CURRENTWORD_MAXLENGTH + MAX_PATH * 2; - TCHAR cmdPure[MAX_PATH]; - TCHAR cmdIntermediate[MAX_PATH]; - TCHAR cmd2Exec[MAX_PATH]; - TCHAR args[MAX_PATH]; - TCHAR argsIntermediate[argsIntermediateLen]; - TCHAR args2Exec[args2ExecLen]; + TCHAR cmdPure[MAX_PATH]{}; + TCHAR cmdIntermediate[MAX_PATH]{}; + TCHAR cmd2Exec[MAX_PATH]{}; + TCHAR args[MAX_PATH]{}; + TCHAR argsIntermediate[argsIntermediateLen]{}; + TCHAR args2Exec[args2ExecLen]{}; extractArgs(cmdPure, MAX_PATH, args, MAX_PATH, _cmdLine.c_str()); int nbTchar = ::ExpandEnvironmentStrings(cmdPure, cmdIntermediate, MAX_PATH); @@ -213,7 +213,7 @@ HINSTANCE Command::run(HWND hWnd, const TCHAR* cwd) expandNppEnvironmentStrs(cmdIntermediate, cmd2Exec, MAX_PATH, hWnd); expandNppEnvironmentStrs(argsIntermediate, args2Exec, args2ExecLen, hWnd); - TCHAR cwd2Exec[MAX_PATH]; + TCHAR cwd2Exec[MAX_PATH]{}; expandNppEnvironmentStrs(cwd, cwd2Exec, MAX_PATH, hWnd); HINSTANCE res = ::ShellExecute(hWnd, TEXT("open"), cmd2Exec, args2Exec, cwd2Exec, SW_SHOW); @@ -253,22 +253,18 @@ intptr_t CALLBACK RunDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam case WM_CTLCOLOREDIT: { - if (NppDarkMode::isEnabled()) - { - return NppDarkMode::onCtlColorSofter(reinterpret_cast(wParam)); - } - break; + return NppDarkMode::onCtlColorSofter(reinterpret_cast(wParam)); } case WM_CTLCOLORLISTBOX: + { + return NppDarkMode::onCtlColorListbox(wParam, lParam); + } + case WM_CTLCOLORDLG: case WM_CTLCOLORSTATIC: { - if (NppDarkMode::isEnabled()) - { - return NppDarkMode::onCtlColorDarker(reinterpret_cast(wParam)); - } - break; + return NppDarkMode::onCtlColorDarker(reinterpret_cast(wParam)); } case WM_PRINTCLIENT: @@ -284,7 +280,7 @@ intptr_t CALLBACK RunDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam { if (NppDarkMode::isEnabled()) { - RECT rc = {}; + RECT rc{}; getClientRect(rc); ::FillRect(reinterpret_cast(wParam), &rc, NppDarkMode::getDarkerBackgroundBrush()); return TRUE; @@ -298,7 +294,7 @@ intptr_t CALLBACK RunDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam return TRUE; } - case WM_COMMAND : + case WM_COMMAND: { switch (wParam) { @@ -308,7 +304,7 @@ intptr_t CALLBACK RunDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam case IDOK : { - TCHAR cmd[MAX_PATH]; + TCHAR cmd[MAX_PATH]{}; ::GetDlgItemText(_hSelf, IDC_COMBO_RUN_PATH, cmd, MAX_PATH); _cmdLine = cmd; @@ -336,7 +332,7 @@ intptr_t CALLBACK RunDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam DynamicMenu& runMenu = nppParams.getRunMenuItems(); int nbTopLevelItem = runMenu.getTopLevelItemNumber(); - TCHAR cmd[MAX_PATH]; + TCHAR cmd[MAX_PATH]{}; ::GetDlgItemText(_hSelf, IDC_COMBO_RUN_PATH, cmd, MAX_PATH); UserCommand uc(Shortcut(), wstring2string(cmd, CP_UTF8).c_str(), cmdID); uc.init(_hInst, _hSelf); @@ -400,7 +396,7 @@ intptr_t CALLBACK RunDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam } } } - return FALSE; + return FALSE; } void RunDlg::addTextToCombo(const TCHAR *txt2Add) const @@ -427,7 +423,7 @@ void RunDlg::doDialog(bool isRTL) NppDarkMode::autoSubclassAndThemeChildControls(_hSelf); - // Adjust the position in the center - goToCenter(); + // Adjust the position in the center + goToCenter(SWP_SHOWWINDOW | SWP_NOSIZE); ::SetFocus(::GetDlgItem(_hSelf, IDC_COMBO_RUN_PATH)); } diff --git a/PowerEditor/src/WinControls/StaticDialog/RunDlg/RunDlg.h b/PowerEditor/src/WinControls/StaticDialog/RunDlg/RunDlg.h index af8ad81f9..5e365af94 100644 --- a/PowerEditor/src/WinControls/StaticDialog/RunDlg/RunDlg.h +++ b/PowerEditor/src/WinControls/StaticDialog/RunDlg/RunDlg.h @@ -16,7 +16,6 @@ #pragma once -#include #include "Common.h" #include "RunDlg_rc.h" @@ -57,10 +56,10 @@ public : RunDlg() = default; void doDialog(bool isRTL = false); - virtual void destroy() {}; + void destroy() override {}; protected : - virtual intptr_t CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam); + intptr_t CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) override; private : void addTextToCombo(const TCHAR *txt2Add) const; diff --git a/PowerEditor/src/WinControls/StaticDialog/RunDlg/RunDlg.rc b/PowerEditor/src/WinControls/StaticDialog/RunDlg/RunDlg.rc index 2f3c03bfe..777de4208 100644 --- a/PowerEditor/src/WinControls/StaticDialog/RunDlg/RunDlg.rc +++ b/PowerEditor/src/WinControls/StaticDialog/RunDlg/RunDlg.rc @@ -21,21 +21,19 @@ along with this program. If not, see . #include "RunDlg_rc.h" #ifndef IDC_STATIC -#define IDC_STATIC -1 +#define IDC_STATIC -1 #endif -IDD_RUN_DLG DIALOGEX 0, 0, 196, 100 +IDD_RUN_DLG DIALOGEX 0, 0, 186, 80 STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_DLGMODALFRAME | WS_EX_WINDOWEDGE CAPTION "Run..." FONT 8, TEXT("MS Shell Dlg"), 400, 0, 0x1 BEGIN - DEFPUSHBUTTON "Run",IDOK,16,74,47,14 - PUSHBUTTON "Cancel",IDCANCEL, 121,74,48,14 - PUSHBUTTON "...",IDC_BUTTON_FILE_BROWSER,154,30,16,14 - COMBOBOX IDC_COMBO_RUN_PATH,14,31,136,71,CBS_DROPDOWN | - CBS_AUTOHSCROLL | CBS_SORT | WS_VSCROLL | WS_TABSTOP - GROUPBOX "The Program to Run",IDC_MAINTEXT_STATIC,7,10, - 172,49,BS_CENTER - PUSHBUTTON "Save...",IDC_BUTTON_SAVE,68,74,50,14 + GROUPBOX "The &Program to Run",IDC_MAINTEXT_STATIC,7,6,172,48,BS_CENTER + COMBOBOX IDC_COMBO_RUN_PATH,14,26,138,71,CBS_DROPDOWN | CBS_AUTOHSCROLL | CBS_SORT | WS_VSCROLL | WS_TABSTOP + PUSHBUTTON "...",IDC_BUTTON_FILE_BROWSER,156,25,16,14 + DEFPUSHBUTTON "&Run",IDOK,16,60,50,14 + PUSHBUTTON "&Save...",IDC_BUTTON_SAVE,69,60,50,14 + PUSHBUTTON "&Cancel",IDCANCEL,122,60,50,14 END diff --git a/PowerEditor/visual.net/notepadPlus.Cpp.props b/PowerEditor/visual.net/notepadPlus.Cpp.props index 7df12d962..3e4876f80 100644 --- a/PowerEditor/visual.net/notepadPlus.Cpp.props +++ b/PowerEditor/visual.net/notepadPlus.Cpp.props @@ -42,7 +42,7 @@ NativeRecommendedRules.ruleset - comctl32.lib;shlwapi.lib;shell32.lib;Oleacc.lib;Dbghelp.lib;Version.lib;Crypt32.lib;wintrust.lib;Sensapi.lib;wininet.lib;imm32.lib;msimg32.lib;uxtheme.lib;libscintilla.lib;liblexilla.lib;%(AdditionalDependencies) + comctl32.lib;shlwapi.lib;shell32.lib;Dbghelp.lib;Version.lib;Crypt32.lib;wintrust.lib;Sensapi.lib;wininet.lib;imm32.lib;msimg32.lib;uxtheme.lib;libscintilla.lib;liblexilla.lib;%(AdditionalDependencies) LinkVerboseLib $(OutDir)notepad++.exe 1.0