Skip to content

Commit

Permalink
Make Find and Replace dialog resizable.
Browse files Browse the repository at this point in the history
  • Loading branch information
zufuliu committed Nov 4, 2018
1 parent 0b47bae commit eed0ef6
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 13 deletions.
44 changes: 39 additions & 5 deletions src/Edit.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,9 @@ extern HWND hDlgFindReplace;
extern UINT cpLastFind;
extern BOOL bReplaceInitialized;

static EDITFINDREPLACE efrSave;
static BOOL bSwitchedFindReplace = FALSE;
static int xFindReplaceDlgSave;
static int yFindReplaceDlgSave;
extern int xFindReplaceDlg;
extern int yFindReplaceDlg;
extern int cxFindReplaceDlg;

extern int iDefaultEncoding;
extern int iDefaultEOLMode;
Expand Down Expand Up @@ -4097,6 +4094,11 @@ extern int iFindReplaceOpacityLevel;
// EditFindReplaceDlgProc()
//
static INT_PTR CALLBACK EditFindReplaceDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) {
static BOOL bSwitchedFindReplace = FALSE;
static int xFindReplaceDlgSave;
static int yFindReplaceDlgSave;
static EDITFINDREPLACE efrSave;

WCHAR tch[NP2_FIND_REPLACE_LIMIT + 32];

switch (umsg) {
Expand All @@ -4106,8 +4108,9 @@ static INT_PTR CALLBACK EditFindReplaceDlgProc(HWND hwnd, UINT umsg, WPARAM wPar
#endif

SetWindowLongPtr(hwnd, DWLP_USER, lParam);
LPEDITFINDREPLACE lpefr = (LPEDITFINDREPLACE)lParam;
ResizeDlg_InitX(hwnd, cxFindReplaceDlg, IDC_RESIZEGRIP2);

LPEDITFINDREPLACE lpefr = (LPEDITFINDREPLACE)lParam;
// Get the current code page for Unicode conversion
const UINT cpEdit = (UINT)SendMessage(lpefr->hwnd, SCI_GETCODEPAGE, 0, 0);

Expand Down Expand Up @@ -4250,6 +4253,37 @@ static INT_PTR CALLBACK EditFindReplaceDlgProc(HWND hwnd, UINT umsg, WPARAM wPar
}
return TRUE;

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

case WM_SIZE: {
int dx;

const BOOL isReplace = GetDlgItem(hwnd, IDC_REPLACETEXT) != NULL;
ResizeDlg_Size(hwnd, lParam, &dx, NULL);
HDWP hdwp = BeginDeferWindowPos(isReplace ? 11 : 6);
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_FINDTEXT, dx, 0, SWP_NOMOVE);
hdwp = DeferCtlPos(hdwp, hwnd, IDC_CLEAR_FIND, dx, 0, SWP_NOSIZE);
hdwp = DeferCtlPos(hdwp, hwnd, IDC_FINDPREV, dx, 0, SWP_NOSIZE);
if (isReplace) {
hdwp = DeferCtlPos(hdwp, hwnd, IDC_REPLACETEXT, dx, 0, SWP_NOMOVE);
hdwp = DeferCtlPos(hdwp, hwnd, IDC_CLEAR_REPLACE, dx, 0, SWP_NOSIZE);
hdwp = DeferCtlPos(hdwp, hwnd, IDC_REPLACE, dx, 0, SWP_NOSIZE);
hdwp = DeferCtlPos(hdwp, hwnd, IDC_REPLACEALL, dx, 0, SWP_NOSIZE);
hdwp = DeferCtlPos(hdwp, hwnd, IDC_REPLACEINSEL, dx, 0, SWP_NOSIZE);
}
EndDeferWindowPos(hdwp);
}
return TRUE;

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

case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDC_FINDTEXT:
Expand Down
3 changes: 3 additions & 0 deletions src/Notepad2.c
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ int cxEncloseSelectionDlg;
int cxInsertTagDlg;
int xFindReplaceDlg;
int yFindReplaceDlg;
int cxFindReplaceDlg;

static LPWSTR lpFileList[32];
static int cFileList = 0;
Expand Down Expand Up @@ -5466,6 +5467,7 @@ void LoadSettings(void) {
cxInsertTagDlg = IniSectionGetInt(pIniSection, L"InsertTagDlgSizeX", 0);
xFindReplaceDlg = IniSectionGetInt(pIniSection, L"FindReplaceDlgPosX", 0);
yFindReplaceDlg = IniSectionGetInt(pIniSection, L"FindReplaceDlgPosY", 0);
cxFindReplaceDlg = IniSectionGetInt(pIniSection, L"FindReplaceDlgSizeX", 0);

if (bSaveFindReplace) {
efrData.fuFlags = 0;
Expand Down Expand Up @@ -5679,6 +5681,7 @@ void SaveSettings(BOOL bSaveSettingsNow) {
IniSectionSetInt(pIniSection, L"InsertTagDlgSizeX", cxInsertTagDlg);
IniSectionSetInt(pIniSection, L"FindReplaceDlgPosX", xFindReplaceDlg);
IniSectionSetInt(pIniSection, L"FindReplaceDlgPosY", yFindReplaceDlg);
IniSectionSetInt(pIniSection, L"FindReplaceDlgSizeX", cxFindReplaceDlg);

if (bSaveFindReplace) {
IniSectionSetBoolEx(pIniSection, L"FindReplaceMatchCase", (efrData.fuFlags & SCFIND_MATCHCASE), 0);
Expand Down
2 changes: 2 additions & 0 deletions src/Notepad2.rc
Original file line number Diff line number Diff line change
Expand Up @@ -927,6 +927,7 @@ BEGIN
//#endif
CONTROL "<a>Clear History</a>",IDC_CLEAR_FIND,"SysLink",WS_TABSTOP,173,7,48,10
CONTROL "Transparent mode on losing focus",IDC_TRANSPARENT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,96,124,10
SCROLLBAR IDC_RESIZEGRIP2,230,96,10,10
END

IDD_REPLACE DIALOGEX 0, 0, 290, 142
Expand Down Expand Up @@ -961,6 +962,7 @@ BEGIN
CONTROL "<a>Clear History</a>",IDC_CLEAR_FIND,"SysLink",WS_TABSTOP,173,6,48,10
CONTROL "<a>Clear History</a>",IDC_CLEAR_REPLACE,"SysLink",WS_TABSTOP,173,35,48,10
CONTROL "Transparent mode on losing focus",IDC_TRANSPARENT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,126,124,10
SCROLLBAR IDC_RESIZEGRIP2,230,126,10,10
END

IDD_RUN DIALOGEX 0, 0, 234, 86
Expand Down
16 changes: 8 additions & 8 deletions src/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
#define IDC_NOUNICODEDETECTION 101
#define IDC_WARNINCONSISTENTEOLS 101
#define IDC_STYLEEDIT 102
#define IDC_FINDCASE 102
#define IDC_OPENWITHDESCR 102
#define IDC_SAVEMRU 102
#define IDD_RUN 102
Expand All @@ -52,7 +51,7 @@
#define IDC_LINE_RANGE 102
#define IDC_EOL_SUM_CRLF 102
#define IDD_DEFENCODING 103
#define IDC_FINDWORD 103
#define IDC_FINDCASE 103
#define IDC_RESIZEGRIP3 103
#define IDB_NEXT 103
#define IDC_STYLEFORE 103
Expand All @@ -61,6 +60,7 @@
#define IDC_EMPTY_MRU 103
#define IDC_EOL_SUM_LF 103
#define IDC_EOL_SUM_CR 104
#define IDC_FINDWORD 104

#define IDD_ABOUT 100
#define IDC_VERSION 100
Expand All @@ -78,25 +78,25 @@
#define IDC_SCI_PAGE_LINK 112

#define IDD_ENCODING 104
#define IDC_FINDSTART 104
#define IDB_PICK 104
#define IDC_STYLEBACK 104
#define IDC_FINDSTART 105
#define IDD_RECODE 105
#define IDC_FINDREGEXP 105
#define IDC_STYLEFONT 105
#define IDB_ENCODING 105
#define IDC_FINDREGEXP 106
#define IDD_DEFEOLMODE 106
#define IDC_FINDTRANSFORMBS 106
#define IDC_PREVIEW 106
#define IDC_FINDTRANSFORMBS 107
#define IDD_FAVORITES 107
#define IDC_NOWRAP 107
#define IDC_STYLEDEFAULT 107
#define IDC_NOWRAP 108
#define IDD_ADDTOFAV 108
#define IDC_PREVSTYLE 108
#define IDC_FINDCLOSE 108
#define IDC_FINDCLOSE 109
#define IDD_FILEMRU 109
#define IDC_FINDPREV 109
#define IDC_NEXTSTYLE 109
#define IDC_FINDPREV 110
#define IDD_CHANGENOTIFY 110
#define IDC_IMPORT 110
#define IDD_MODIFYLINES 111
Expand Down

0 comments on commit eed0ef6

Please sign in to comment.