Reorder tab focus in Run dlg

Plus:
- add key accelerators.
- remove unneeded library.
- add initializers.

Fix #13540, close #13541
This commit is contained in:
ozone10 2023-04-16 10:34:19 +02:00 committed by Don Ho
parent 15decdb3d9
commit 3cf45ec3a8
4 changed files with 33 additions and 40 deletions

View File

@ -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<HDC>(wParam));
}
break;
return NppDarkMode::onCtlColorSofter(reinterpret_cast<HDC>(wParam));
}
case WM_CTLCOLORLISTBOX:
{
return NppDarkMode::onCtlColorListbox(wParam, lParam);
}
case WM_CTLCOLORDLG:
case WM_CTLCOLORSTATIC:
{
if (NppDarkMode::isEnabled())
{
return NppDarkMode::onCtlColorDarker(reinterpret_cast<HDC>(wParam));
}
break;
return NppDarkMode::onCtlColorDarker(reinterpret_cast<HDC>(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<HDC>(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));
}

View File

@ -16,7 +16,6 @@
#pragma once
#include <oleacc.h>
#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;

View File

@ -21,21 +21,19 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
#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

View File

@ -42,7 +42,7 @@
<AnalyzeExternalRuleset>NativeRecommendedRules.ruleset</AnalyzeExternalRuleset>
</ClCompile>
<Link>
<AdditionalDependencies>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)</AdditionalDependencies>
<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)</AdditionalDependencies>
<ShowProgress>LinkVerboseLib</ShowProgress>
<OutputFile>$(OutDir)notepad++.exe</OutputFile>
<Version>1.0</Version>