Skip to content

Commit

Permalink
Make "Enclose Selection" dialog resizable.
Browse files Browse the repository at this point in the history
  • Loading branch information
zufuliu committed Nov 4, 2018
1 parent 61a4ef3 commit b5a99cc
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 11 deletions.
40 changes: 31 additions & 9 deletions src/Edit.c
Original file line number Diff line number Diff line change
Expand Up @@ -5329,6 +5329,7 @@ typedef struct _modlinesdata {
} MODLINESDATA, *PMODLINESDATA;

extern int cxModifyLinesDlg;
extern int cxEncloseSelectionDlg;

static INT_PTR CALLBACK EditModifyLinesDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) {
static int id_hover;
Expand Down Expand Up @@ -5592,8 +5593,6 @@ BOOL EditAlignDlg(HWND hwnd, int *piAlignMode) {
//
// EditEncloseSelectionDlgProc()
//
// Controls: 100 Input
// 101 Input
//

typedef struct _encloseselectiondata {
Expand All @@ -5605,23 +5604,46 @@ static INT_PTR CALLBACK EditEncloseSelectionDlgProc(HWND hwnd, UINT umsg, WPARAM
switch (umsg) {
case WM_INITDIALOG: {
SetWindowLongPtr(hwnd, DWLP_USER, lParam);
PENCLOSESELDATA pdata = (PENCLOSESELDATA)lParam;
ResizeDlg_InitX(hwnd, cxEncloseSelectionDlg, IDC_RESIZEGRIP2);

SendDlgItemMessage(hwnd, 100, EM_LIMITTEXT, 255, 0);
SetDlgItemText(hwnd, 100, pdata->pwsz1);
SendDlgItemMessage(hwnd, 101, EM_LIMITTEXT, 255, 0);
SetDlgItemText(hwnd, 101, pdata->pwsz2);
PENCLOSESELDATA pdata = (PENCLOSESELDATA)lParam;
SendDlgItemMessage(hwnd, IDC_MODIFY_LINE_PREFIX, EM_LIMITTEXT, 255, 0);
SetDlgItemText(hwnd, IDC_MODIFY_LINE_PREFIX, pdata->pwsz1);
SendDlgItemMessage(hwnd, IDC_MODIFY_LINE_APPEND, EM_LIMITTEXT, 255, 0);
SetDlgItemText(hwnd, IDC_MODIFY_LINE_APPEND, pdata->pwsz2);
CenterDlgInParent(hwnd);
}
return TRUE;

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

case WM_SIZE: {
int dx;

ResizeDlg_Size(hwnd, lParam, &dx, NULL);
HDWP hdwp = BeginDeferWindowPos(5);
hdwp = DeferCtlPos(hdwp, hwnd, IDC_RESIZEGRIP2, 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_MODIFY_LINE_PREFIX, dx, 0, SWP_NOMOVE);
hdwp = DeferCtlPos(hdwp, hwnd, IDC_MODIFY_LINE_APPEND, dx, 0, SWP_NOMOVE);
EndDeferWindowPos(hdwp);
}
return TRUE;

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

case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDOK: {
PENCLOSESELDATA pdata = (PENCLOSESELDATA)GetWindowLongPtr(hwnd, DWLP_USER);
if (pdata) {
GetDlgItemText(hwnd, 100, pdata->pwsz1, 256);
GetDlgItemText(hwnd, 101, pdata->pwsz2, 256);
GetDlgItemText(hwnd, IDC_MODIFY_LINE_PREFIX, pdata->pwsz1, 256);
GetDlgItemText(hwnd, IDC_MODIFY_LINE_APPEND, pdata->pwsz2, 256);
}
EndDialog(hwnd, IDOK);
}
Expand Down
3 changes: 3 additions & 0 deletions src/Notepad2.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ int cxFavoritesDlg;
int cyFavoritesDlg;
int cxAddFavoritesDlg;
int cxModifyLinesDlg;
int cxEncloseSelectionDlg;
int xFindReplaceDlg;
int yFindReplaceDlg;

Expand Down Expand Up @@ -5460,6 +5461,7 @@ void LoadSettings(void) {
cyFavoritesDlg = IniSectionGetInt(pIniSection, L"FavoritesDlgSizeY", 0);
cxAddFavoritesDlg = IniSectionGetInt(pIniSection, L"AddFavoritesDlgSizeX", 0);
cxModifyLinesDlg = IniSectionGetInt(pIniSection, L"ModifyLinesDlgSizeX", 0);
cxEncloseSelectionDlg = IniSectionGetInt(pIniSection, L"EncloseSelectionDlgSizeX", 0);
xFindReplaceDlg = IniSectionGetInt(pIniSection, L"FindReplaceDlgPosX", 0);
yFindReplaceDlg = IniSectionGetInt(pIniSection, L"FindReplaceDlgPosY", 0);

Expand Down Expand Up @@ -5671,6 +5673,7 @@ void SaveSettings(BOOL bSaveSettingsNow) {
IniSectionSetInt(pIniSection, L"FavoritesDlgSizeY", cyFavoritesDlg);
IniSectionSetInt(pIniSection, L"AddFavoritesDlgSizeX", cxAddFavoritesDlg);
IniSectionSetInt(pIniSection, L"ModifyLinesDlgSizeX", cxModifyLinesDlg);
IniSectionSetInt(pIniSection, L"EncloseSelectionDlgSizeX", cxEncloseSelectionDlg);
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 @@ -1293,11 +1293,12 @@ CAPTION "Enclose Selection"
FONT 8, "MS Shell Dlg", 0, 0, 0x0
BEGIN
LTEXT "Insert &before selection:",IDC_STATIC,7,7,114,8
EDITTEXT 100,7,18,234,14,ES_AUTOHSCROLL
EDITTEXT IDC_MODIFY_LINE_PREFIX,7,18,234,14,ES_AUTOHSCROLL
LTEXT "Insert &after selection:",IDC_STATIC,7,37,116,8
EDITTEXT 101,7,48,234,14,ES_AUTOHSCROLL
EDITTEXT IDC_MODIFY_LINE_APPEND,7,48,234,14,ES_AUTOHSCROLL
DEFPUSHBUTTON "OK",IDOK,135,73,50,14
PUSHBUTTON "Cancel",IDCANCEL,191,73,50,14
SCROLLBAR IDC_RESIZEGRIP2,7,73,10,10
END

IDD_INFOBOX DIALOGEX 0, 0, 244, 88
Expand Down

0 comments on commit b5a99cc

Please sign in to comment.