Skip to content

Commit

Permalink
Make metapath's "Find Window" dialog resizable.
Browse files Browse the repository at this point in the history
  • Loading branch information
zufuliu committed Nov 4, 2018
1 parent b3490bb commit 20bdae8
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 3 deletions.
28 changes: 26 additions & 2 deletions metapath/src/Dialogs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1868,23 +1868,44 @@ BOOL NewDirDlg(HWND hwnd, LPWSTR pszNewDir) {
// Find target window helper dialog
//
extern int flagPortableMyDocs;
extern int cxFindWindowDlg;

static INT_PTR CALLBACK FindWinDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) {
static WCHAR *pTargetWndClassBuf;
static HICON hIconCross1, hIconCross2;
static HCURSOR hCursorCross;
static BOOL bHasCapture;

switch (umsg) {
case WM_INITDIALOG:
pTargetWndClassBuf = (WCHAR *)lParam;
SetWindowLongPtr(hwnd, DWLP_USER, lParam);
ResizeDlg_InitX(hwnd, cxFindWindowDlg, IDC_RESIZEGRIP2);

hIconCross1 = LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_CROSS1));
hIconCross2 = LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_CROSS2));
hCursorCross = LoadCursor(g_hInstance, MAKEINTRESOURCE(IDC_CROSSHAIR));
CenterDlgInParent(hwnd);
bHasCapture = FALSE;
return TRUE;

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_FINDWINDESC, dx, 0, SWP_NOMOVE);
hdwp = DeferCtlPos(hdwp, hwnd, IDC_WINTITLE, dx, 0, SWP_NOMOVE);
EndDeferWindowPos(hdwp);
InvalidateRect(GetDlgItem(hwnd, IDC_FINDWINDESC), NULL, TRUE);
}
return TRUE;

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

case WM_CANCELMODE:
ReleaseCapture();
bHasCapture = FALSE;
Expand Down Expand Up @@ -1921,6 +1942,7 @@ static INT_PTR CALLBACK FindWinDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPAR
//}
//
//if (GetDlgItemText(hwnd, IDC_WINCLASS, tch, COUNTOF(tch))) {
// LPWSTR pTargetWndClassBuf = (LPWSTR)GetWindowLongPtr(hwnd, DWLP_USER);
// lstrcpyn(pTargetWndClassBuf, tch, 256);
// PostMessage(hwnd, WM_CLOSE, 0, 0);
//}
Expand Down Expand Up @@ -1969,6 +1991,7 @@ static INT_PTR CALLBACK FindWinDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPAR
}

if (GetDlgItemText(hwnd, IDC_WINCLASS, tch, COUNTOF(tch))) {
LPWSTR pTargetWndClassBuf = (LPWSTR)GetWindowLongPtr(hwnd, DWLP_USER);
lstrcpyn(pTargetWndClassBuf, tch, 256);
}
EndDialog(hwnd, IDOK);
Expand All @@ -1981,6 +2004,7 @@ static INT_PTR CALLBACK FindWinDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPAR
return TRUE;

case WM_DESTROY:
ResizeDlg_Destroy(hwnd, &cxFindWindowDlg, NULL);
if (bHasCapture) {
ReleaseCapture();
SendMessage(hwnd, WM_LBUTTONUP, 0, 0);
Expand Down
3 changes: 3 additions & 0 deletions metapath/src/metapath.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ int cxNewDirectoryDlg;
int cxOpenWithDlg;
int cyOpenWithDlg;
int cxCopyMoveDlg;
int cxFindWindowDlg;

WCHAR tchFilter[DL_FILTER_BUFSIZE];
BOOL bNegFilter;
Expand Down Expand Up @@ -2477,6 +2478,7 @@ void LoadSettings(void) {
cxOpenWithDlg = IniSectionGetInt(pIniSection, L"OpenWithDlgSizeX", 0);
cyOpenWithDlg = IniSectionGetInt(pIniSection, L"OpenWithDlgSizeY", 0);
cxCopyMoveDlg = IniSectionGetInt(pIniSection, L"CopyMoveDlgSizeX", 0);
cxFindWindowDlg = IniSectionGetInt(pIniSection, L"FindWindowDlgSizeX", 0);

if (!flagPosParam) {
// ignore window position if /p was specified
Expand Down Expand Up @@ -2608,6 +2610,7 @@ void SaveSettings(BOOL bSaveSettingsNow) {
IniSectionSetInt(pIniSection, L"OpenWithDlgSizeX", cxOpenWithDlg);
IniSectionSetInt(pIniSection, L"OpenWithDlgSizeY", cyOpenWithDlg);
IniSectionSetInt(pIniSection, L"CopyMoveDlgSizeX", cxCopyMoveDlg);
IniSectionSetInt(pIniSection, L"FindWindowDlgSizeX", cxFindWindowDlg);

SaveIniSection(INI_SECTION_NAME_SETTINGS, pIniSectionBuf);
NP2HeapFree(pIniSectionBuf);
Expand Down
3 changes: 2 additions & 1 deletion metapath/src/metapath.rc
Original file line number Diff line number Diff line change
Expand Up @@ -503,13 +503,14 @@ FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
ICON IDI_CROSS1,IDC_CROSSCURSOR,7,7,21,20,SS_CENTERIMAGE
LTEXT "Drag the crosshair over the window you would like to select as the new target, or press Esc to cancel.",
IDC_STATIC,35,7,168,22
IDC_FINDWINDESC,35,7,168,22
EDITTEXT IDC_WINTITLE,7,35,196,14,ES_AUTOHSCROLL | ES_READONLY |
NOT WS_TABSTOP
LTEXT "Window Class",IDC_WINCLASS,7,60,45,8,NOT WS_VISIBLE
LTEXT "Window Module",IDC_WINMODULE,7,70,51,8,NOT WS_VISIBLE
DEFPUSHBUTTON "OK",IDOK,97,64,50,14,WS_DISABLED
PUSHBUTTON "Cancel",IDCANCEL,153,64,50,14
SCROLLBAR IDC_RESIZEGRIP2,7,64,10,10
END


Expand Down
1 change: 1 addition & 0 deletions metapath/src/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
#define IDC_ALWAYSONTOP 104
#define IDI_OPTIONS2 104
#define IDC_AUTHORNAME 104
#define IDC_FINDWINDESC 104
#define IDD_COPYMOVE 105
#define IDC_RESIZEGRIP2 105
#define IDC_USERECYCLEBIN 105
Expand Down

0 comments on commit 20bdae8

Please sign in to comment.