Skip to content

Commit

Permalink
Make "Run" dialog resizable.
Browse files Browse the repository at this point in the history
  • Loading branch information
zufuliu committed Nov 4, 2018
1 parent 01a00bb commit 2b6d835
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 3 deletions.
22 changes: 22 additions & 0 deletions metapath/src/Dialogs.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,14 @@ extern WCHAR szCurDir[MAX_PATH + 40];
//
//
extern HWND hwndDirList;
extern int cxRunDlg;

INT_PTR CALLBACK RunDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) {
UNREFERENCED_PARAMETER(lParam);

switch (umsg) {
case WM_INITDIALOG: {
ResizeDlg_InitX(hwnd, cxRunDlg, IDC_RESIZEGRIP3);
MakeBitmapButton(hwnd, IDC_SEARCHEXE, g_hInstance, IDB_OPEN);

DLITEM dli;
Expand All @@ -188,9 +190,29 @@ INT_PTR CALLBACK RunDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
return TRUE;

case WM_DESTROY:
ResizeDlg_Destroy(hwnd, &cxRunDlg, NULL);
DeleteBitmapButton(hwnd, IDC_SEARCHEXE);
return FALSE;

case WM_SIZE: {
int dx;

ResizeDlg_Size(hwnd, lParam, &dx, NULL);
HDWP hdwp = BeginDeferWindowPos(5);
hdwp = DeferCtlPos(hdwp, hwnd, IDC_RESIZEGRIP3, dx, 0, SWP_NOSIZE);
hdwp = DeferCtlPos(hdwp, hwnd, IDOK, dx, 0, SWP_NOSIZE);
hdwp = DeferCtlPos(hdwp, hwnd, IDCANCEL, dx, 0, SWP_NOSIZE);
hdwp = DeferCtlPos(hdwp, hwnd, IDC_SEARCHEXE, dx, 0, SWP_NOSIZE);
hdwp = DeferCtlPos(hdwp, hwnd, IDC_COMMANDLINE, dx, 0, SWP_NOMOVE);
EndDeferWindowPos(hdwp);
ResizeDlgCtl(hwnd, IDC_RUNDESC, dx, 0);
}
return TRUE;

case WM_GETMINMAXINFO:
ResizeDlg_GetMinMaxInfo(hwnd, lParam);
return TRUE;

case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDC_SEARCHEXE: {
Expand Down
3 changes: 3 additions & 0 deletions metapath/src/metapath.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ BOOL fNoConfirmDelete;
static BOOL bShowToolbar;
static BOOL bShowStatusbar;
static BOOL bShowDriveBox;
int cxRunDlg;
int cxGotoDlg;
int cxOpenWithDlg;
int cyOpenWithDlg;
Expand Down Expand Up @@ -2465,6 +2466,7 @@ void LoadSettings(void) {
bShowStatusbar = IniSectionGetBool(pIniSection, L"ShowStatusbar", 1);
bShowDriveBox = IniSectionGetBool(pIniSection, L"ShowDriveBox", 1);

cxRunDlg = IniSectionGetInt(pIniSection, L"RunDlgSizeX", 0);
cxGotoDlg = IniSectionGetInt(pIniSection, L"GotoDlgSizeX", 0);
cxOpenWithDlg = IniSectionGetInt(pIniSection, L"OpenWithDlgSizeX", 0);
cyOpenWithDlg = IniSectionGetInt(pIniSection, L"OpenWithDlgSizeY", 0);
Expand Down Expand Up @@ -2592,6 +2594,7 @@ void SaveSettings(BOOL bSaveSettingsNow) {
IniSectionSetBoolEx(pIniSection, L"ShowToolbar", bShowToolbar, 1);
IniSectionSetBoolEx(pIniSection, L"ShowStatusbar", bShowStatusbar, 1);
IniSectionSetBoolEx(pIniSection, L"ShowDriveBox", bShowDriveBox, 1);
IniSectionSetInt(pIniSection, L"RunDlgSizeX", cxRunDlg);
IniSectionSetInt(pIniSection, L"GotoDlgSizeX", cxGotoDlg);
IniSectionSetInt(pIniSection, L"OpenWithDlgSizeX", cxOpenWithDlg);
IniSectionSetInt(pIniSection, L"OpenWithDlgSizeY", cyOpenWithDlg);
Expand Down
5 changes: 3 additions & 2 deletions metapath/src/metapath.rc
Original file line number Diff line number Diff line change
Expand Up @@ -247,12 +247,13 @@ CAPTION "Run"
FONT 8, "MS Shell Dlg", 0, 0, 0x0
BEGIN
ICON IDI_RUN,IDC_STATIC,7,7,20,20
LTEXT "Enter the name of an executable program file,\na folder or a document to open.",
IDC_STATIC,35,7,188,17
LTEXT "Enter the name of an executable program file, a folder or a document to open.",
IDC_RUNDESC,35,7,188,17
EDITTEXT IDC_COMMANDLINE,7,35,203,14,ES_AUTOHSCROLL
PUSHBUTTON "",IDC_SEARCHEXE,215,35,14,14
DEFPUSHBUTTON "OK",IDOK,121,65,50,14
PUSHBUTTON "Cancel",IDCANCEL,177,65,50,14
SCROLLBAR IDC_RESIZEGRIP3,7,65,10,10
END

IDD_OPENWITH DIALOGEX 0, 0, 165, 128
Expand Down
1 change: 1 addition & 0 deletions metapath/src/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#define IDC_SEARCHEXE 101
#define IDB_OPEN 101
#define IDD_RUN 101
#define IDC_RUNDESC 102
#define IDC_NEWNAME 101
#define IDC_DESTINATION 101
#define IDC_GOTOMRU 101
Expand Down
22 changes: 22 additions & 0 deletions src/Dialogs.c
Original file line number Diff line number Diff line change
Expand Up @@ -337,9 +337,11 @@ INT_PTR CALLBACK AboutDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam
//
// RunDlgProc()
//
extern int cxRunDlg;
static INT_PTR CALLBACK RunDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) {
switch (umsg) {
case WM_INITDIALOG: {
ResizeDlg_InitX(hwnd, cxRunDlg, IDC_RESIZEGRIP3);
MakeBitmapButton(hwnd, IDC_SEARCHEXE, g_hInstance, IDB_OPEN);

SendDlgItemMessage(hwnd, IDC_COMMANDLINE, EM_LIMITTEXT, MAX_PATH - 1, 0);
Expand All @@ -351,9 +353,29 @@ static INT_PTR CALLBACK RunDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM l
return TRUE;

case WM_DESTROY:
ResizeDlg_Destroy(hwnd, &cxRunDlg, NULL);
DeleteBitmapButton(hwnd, IDC_SEARCHEXE);
return FALSE;

case WM_SIZE: {
int dx;

ResizeDlg_Size(hwnd, lParam, &dx, NULL);
HDWP hdwp = BeginDeferWindowPos(5);
hdwp = DeferCtlPos(hdwp, hwnd, IDC_RESIZEGRIP3, dx, 0, SWP_NOSIZE);
hdwp = DeferCtlPos(hdwp, hwnd, IDOK, dx, 0, SWP_NOSIZE);
hdwp = DeferCtlPos(hdwp, hwnd, IDCANCEL, dx, 0, SWP_NOSIZE);
hdwp = DeferCtlPos(hdwp, hwnd, IDC_SEARCHEXE, dx, 0, SWP_NOSIZE);
hdwp = DeferCtlPos(hdwp, hwnd, IDC_COMMANDLINE, dx, 0, SWP_NOMOVE);
EndDeferWindowPos(hdwp);
ResizeDlgCtl(hwnd, IDC_RUNDESC, dx, 0);
}
return TRUE;

case WM_GETMINMAXINFO:
ResizeDlg_GetMinMaxInfo(hwnd, lParam);
return TRUE;

case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDC_SEARCHEXE: {
Expand Down
3 changes: 3 additions & 0 deletions src/Notepad2.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ static int cyReBarFrame;
static int cxEditFrame;
static int cyEditFrame;

int cxRunDlg;
int cxEncodingDlg;
int cyEncodingDlg;
int cxRecodeDlg;
Expand Down Expand Up @@ -5444,6 +5445,7 @@ void LoadSettings(void) {
bFullScreenHideToolbar = IniSectionGetBool(pIniSection, L"FullScreenHideToolbar", 0);
bFullScreenHideStatusbar = IniSectionGetBool(pIniSection, L"FullScreenHideStatusbar", 0);

cxRunDlg = IniSectionGetInt(pIniSection, L"RunDlgSizeX", 0);
cxEncodingDlg = IniSectionGetInt(pIniSection, L"EncodingDlgSizeX", 0);
cyEncodingDlg = IniSectionGetInt(pIniSection, L"EncodingDlgSizeY", 0);
cxRecodeDlg = IniSectionGetInt(pIniSection, L"RecodeDlgSizeX", 0);
Expand Down Expand Up @@ -5652,6 +5654,7 @@ void SaveSettings(BOOL bSaveSettingsNow) {
IniSectionSetBoolEx(pIniSection, L"FullScreenHideMenu", bFullScreenHideMenu, 0);
IniSectionSetBoolEx(pIniSection, L"FullScreenHideToolbar", bFullScreenHideToolbar, 0);
IniSectionSetBoolEx(pIniSection, L"FullScreenHideStatusbar", bFullScreenHideStatusbar, 0);
IniSectionSetInt(pIniSection, L"RunDlgSizeX", cxRunDlg);
IniSectionSetInt(pIniSection, L"EncodingDlgSizeX", cxEncodingDlg);
IniSectionSetInt(pIniSection, L"EncodingDlgSizeY", cyEncodingDlg);
IniSectionSetInt(pIniSection, L"RecodeDlgSizeX", cxRecodeDlg);
Expand Down
3 changes: 2 additions & 1 deletion src/Notepad2.rc
Original file line number Diff line number Diff line change
Expand Up @@ -969,11 +969,12 @@ CAPTION "Run"
FONT 8, "MS Shell Dlg", 0, 0, 0x0
BEGIN
ICON IDI_RUN,IDC_STATIC,7,7,21,20
LTEXT "Enter the name of an executable program file,\na folder or a document to open.",IDC_STATIC,35,7,188,17
LTEXT "Enter the name of an executable program file, a folder or a document to open.",IDC_RUNDESC,35,7,188,17
EDITTEXT IDC_COMMANDLINE,7,35,203,14,ES_AUTOHSCROLL
PUSHBUTTON "",IDC_SEARCHEXE,215,35,14,14
DEFPUSHBUTTON "OK",IDOK,121,65,50,14
PUSHBUTTON "Cancel",IDCANCEL,177,65,50,14
SCROLLBAR IDC_RESIZEGRIP3,7,65,10,10
END

IDD_OPENWITH DIALOGEX 0, 0, 228, 206
Expand Down
1 change: 1 addition & 0 deletions src/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#define IDC_OPENWITHDESCR 102
#define IDC_SAVEMRU 102
#define IDD_RUN 102
#define IDC_RUNDESC 102
#define IDC_AUTOSELECT 102
#define IDC_FAVORITESDESCR 102
#define IDC_INFOBOXCHECK 102
Expand Down

0 comments on commit 2b6d835

Please sign in to comment.