Skip to content

Commit

Permalink
Make "Add to Favorites" dialog resizable.
Browse files Browse the repository at this point in the history
  • Loading branch information
zufuliu committed Nov 4, 2018
1 parent 2afad02 commit 00dbe0c
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 10 deletions.
39 changes: 31 additions & 8 deletions src/Dialogs.c
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,7 @@ extern WCHAR tchFavoritesDir[MAX_PATH];

extern int cxFavoritesDlg;
extern int cyFavoritesDlg;
extern int cxAddFavoritesDlg;

static INT_PTR CALLBACK FavoritesDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) {
switch (umsg) {
Expand Down Expand Up @@ -708,7 +709,6 @@ static INT_PTR CALLBACK FavoritesDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LP
case WM_DESTROY:
DirList_Destroy(GetDlgItem(hwnd, IDC_FAVORITESDIR));
DeleteBitmapButton(hwnd, IDC_GETFAVORITESDIR);

ResizeDlg_Destroy(hwnd, &cxFavoritesDlg, &cyFavoritesDlg);
return FALSE;

Expand Down Expand Up @@ -823,30 +823,53 @@ BOOL FavoritesDlg(HWND hwnd, LPWSTR lpstrFile) {
//
// AddToFavDlgProc()
//
// Controls: 100 Edit
//
static INT_PTR CALLBACK AddToFavDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) {
switch (umsg) {
case WM_INITDIALOG: {
SetWindowLongPtr(hwnd, DWLP_USER, lParam);
LPWSTR pszName = (LPWSTR)lParam;
ResizeDlg_InitX(hwnd, cxAddFavoritesDlg, IDC_RESIZEGRIP);

SendDlgItemMessage(hwnd, 100, EM_LIMITTEXT, MAX_PATH - 1, 0);
SetDlgItemText(hwnd, 100, pszName);
LPWSTR pszName = (LPWSTR)lParam;
SendDlgItemMessage(hwnd, IDC_FAVORITESFILE, EM_LIMITTEXT, MAX_PATH - 1, 0);
SetDlgItemText(hwnd, IDC_FAVORITESFILE, pszName);

CenterDlgInParent(hwnd);
}
return TRUE;

case WM_DESTROY:
ResizeDlg_Destroy(hwnd, &cxAddFavoritesDlg, NULL);
return FALSE;

case WM_SIZE: {
int dx;

ResizeDlg_Size(hwnd, lParam, &dx, NULL);
HDWP hdwp = BeginDeferWindowPos(5);
hdwp = DeferCtlPos(hdwp, hwnd, IDC_RESIZEGRIP, 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_FAVORITESDESCR, dx, 0, SWP_NOMOVE);
hdwp = DeferCtlPos(hdwp, hwnd, IDC_FAVORITESFILE, dx, 0, SWP_NOMOVE);
EndDeferWindowPos(hdwp);
InvalidateRect(GetDlgItem(hwnd, IDC_FAVORITESDESCR), NULL, TRUE);
}
return TRUE;

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

case WM_COMMAND:
switch (LOWORD(wParam)) {
case 100:
EnableWindow(GetDlgItem(hwnd, IDOK), GetWindowTextLength(GetDlgItem(hwnd, 100)));
case IDC_FAVORITESFILE:
EnableWindow(GetDlgItem(hwnd, IDOK), GetWindowTextLength(GetDlgItem(hwnd, IDC_FAVORITESFILE)));
break;

case IDOK: {
LPWSTR pszName = (LPWSTR)GetWindowLongPtr(hwnd, DWLP_USER);
GetDlgItemText(hwnd, 100, pszName, MAX_PATH - 1);
GetDlgItemText(hwnd, IDC_FAVORITESFILE, pszName, MAX_PATH - 1);
EndDialog(hwnd, IDOK);
}
break;
Expand Down
3 changes: 3 additions & 0 deletions src/Notepad2.c
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ int cxOpenWithDlg;
int cyOpenWithDlg;
int cxFavoritesDlg;
int cyFavoritesDlg;
int cxAddFavoritesDlg;
int xFindReplaceDlg;
int yFindReplaceDlg;

Expand Down Expand Up @@ -5456,6 +5457,7 @@ void LoadSettings(void) {
cyOpenWithDlg = IniSectionGetInt(pIniSection, L"OpenWithDlgSizeY", 0);
cxFavoritesDlg = IniSectionGetInt(pIniSection, L"FavoritesDlgSizeX", 0);
cyFavoritesDlg = IniSectionGetInt(pIniSection, L"FavoritesDlgSizeY", 0);
cxAddFavoritesDlg = IniSectionGetInt(pIniSection, L"AddFavoritesDlgSizeX", 0);
xFindReplaceDlg = IniSectionGetInt(pIniSection, L"FindReplaceDlgPosX", 0);
yFindReplaceDlg = IniSectionGetInt(pIniSection, L"FindReplaceDlgPosY", 0);

Expand Down Expand Up @@ -5665,6 +5667,7 @@ void SaveSettings(BOOL bSaveSettingsNow) {
IniSectionSetInt(pIniSection, L"OpenWithDlgSizeY", cyOpenWithDlg);
IniSectionSetInt(pIniSection, L"FavoritesDlgSizeX", cxFavoritesDlg);
IniSectionSetInt(pIniSection, L"FavoritesDlgSizeY", cyFavoritesDlg);
IniSectionSetInt(pIniSection, L"AddFavoritesDlgSizeX", cxAddFavoritesDlg);
IniSectionSetInt(pIniSection, L"FindReplaceDlgPosX", xFindReplaceDlg);
IniSectionSetInt(pIniSection, L"FindReplaceDlgPosY", yFindReplaceDlg);

Expand Down
5 changes: 3 additions & 2 deletions src/Notepad2.rc
Original file line number Diff line number Diff line change
Expand Up @@ -1233,10 +1233,11 @@ STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSM
CAPTION "Add to Favorites"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
LTEXT "Enter the name for the new favorites item:",IDC_STATIC,7,7,240,8
EDITTEXT 100,7,22,240,14,ES_AUTOHSCROLL
LTEXT "Enter the name for the new favorites item:",IDC_FAVORITESDESCR,7,7,240,8
EDITTEXT IDC_FAVORITESFILE,7,22,240,14,ES_AUTOHSCROLL
DEFPUSHBUTTON "OK",IDOK,141,45,50,14,WS_DISABLED
PUSHBUTTON "Cancel",IDCANCEL,197,45,50,14
SCROLLBAR IDC_RESIZEGRIP,7,45,10,10
END

IDD_COLUMNWRAP DIALOGEX 0, 0, 130, 47
Expand Down
1 change: 1 addition & 0 deletions src/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#define IDC_FILEMRU 100
#define IDC_STYLELIST 100
#define IDC_FAVORITESDIR 100
#define IDC_FAVORITESFILE 100
#define IDC_COLUMNWRAP 100
#define IDC_INFOBOXICON 100
#define IDC_COPY 100
Expand Down

0 comments on commit 00dbe0c

Please sign in to comment.