Cleanup code.

Changed main "ghost" window to a message-only window.
This commit is contained in:
2022-02-21 16:44:06 +03:00
parent 7c73a52f0a
commit 8fbd6f1bde
2 changed files with 150 additions and 158 deletions

View File

@@ -55,7 +55,8 @@ INT_PTR CALLBACK About(HWND, UINT, WPARAM, LPARAM);
VOID MoveWindowToMonitorCenter(HWND hwnd, BOOL bWorkArea, BOOL bResize) VOID MoveWindowToMonitorCenter(HWND hwnd, BOOL bWorkArea, BOOL bResize)
{ {
diag_log(L"Entering MoveWindowToMonitorCenter(): hwnd =", hwnd, L"Title:", (LPWSTR)szBuffer); //diag_log(L"Entering MoveWindowToMonitorCenter(): hwnd =", hwnd, L"Title:", (LPWSTR)szBuffer);
diag_log(L"Entering MoveWindowToMonitorCenter(): hwnd =", hwnd);
RECT fgwrc = { 0 }; RECT fgwrc = { 0 };
GetWindowRect(hwnd, &fgwrc); GetWindowRect(hwnd, &fgwrc);
@@ -136,7 +137,7 @@ int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmd
} }
MyRegisterClass(hInstance); MyRegisterClass(hInstance);
hWnd = CreateWindowExW(0, szClass, szTitle, 0, 0, 0, 0, 0, NULL, NULL, hInstance, NULL); hWnd = CreateWindowExW(0, szClass, szTitle, 0, 0, 0, 0, 0, HWND_MESSAGE, NULL, hInstance, NULL);
if (!hWnd) if (!hWnd)
{ {
ShowError(IDS_ERR_WND); ShowError(IDS_ERR_WND);
@@ -146,8 +147,8 @@ int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmd
int nArgs = 0; int nArgs = 0;
LPWSTR* szArglist = CommandLineToArgvW(GetCommandLineW(), &nArgs); LPWSTR* szArglist = CommandLineToArgvW(GetCommandLineW(), &nArgs);
diag_log(L"Arguments:", nArgs); diag_log(L"Arguments:", nArgs - 1);
for (int i = 0; i < nArgs; i++) for (int i = 1; i < nArgs; i++)
{ {
diag_log(L"Argument", i, L":", szArglist[i]); diag_log(L"Argument", i, L":", szArglist[i]);
} }
@@ -221,10 +222,8 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
bWorkArea ? mii.fState = MFS_CHECKED : mii.fState = MFS_UNCHECKED; bWorkArea ? mii.fState = MFS_CHECKED : mii.fState = MFS_UNCHECKED;
SetMenuItemInfoW(hPopup, ID_POPUPMENU_AREA, FALSE, &mii); SetMenuItemInfoW(hPopup, ID_POPUPMENU_AREA, FALSE, &mii);
//nid.cbSize = sizeof(NOTIFYICONDATAW); nid.cbSize = sizeof(NOTIFYICONDATAW);
nid.cbSize = sizeof(nid);
nid.hWnd = hWnd; nid.hWnd = hWnd;
//nid.uVersion = NOTIFYICON_VERSION_4;
nid.uVersion = NOTIFYICON_VERSION; nid.uVersion = NOTIFYICON_VERSION;
nid.uCallbackMessage = WM_WCW; nid.uCallbackMessage = WM_WCW;
nid.hIcon = hIcon; nid.hIcon = hIcon;
@@ -233,8 +232,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
nid.dwInfoFlags = NIIF_NONE; nid.dwInfoFlags = NIIF_NONE;
nid.dwState = NIS_HIDDEN; nid.dwState = NIS_HIDDEN;
nid.dwStateMask = NIS_HIDDEN; nid.dwStateMask = NIS_HIDDEN;
//StringCchCopyW(nid.szTip, _countof(nid.szTip), szTitle); StringCchCopyW(nid.szTip, _countof(nid.szTip), szTitle);
StringCchCopyW(nid.szTip, ARRAYSIZE(nid.szTip), szTitle);
hMouseHook = SetWindowsHookExW(WH_MOUSE_LL, MouseHookProc, hInst, NULL); hMouseHook = SetWindowsHookExW(WH_MOUSE_LL, MouseHookProc, hInst, NULL);
if (!hMouseHook) if (!hMouseHook)
@@ -255,8 +253,8 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
diag_log(L"Keyboard hook was successfully set"); diag_log(L"Keyboard hook was successfully set");
LoadStringW(hInst, IDS_ABOUT, szAbout, _countof(szAbout)); LoadStringW(hInst, IDS_ABOUT, szAbout, _countof(szAbout));
}
break; break;
}
case WM_WCW: case WM_WCW:
{ {
@@ -287,14 +285,14 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
} }
if (idMenu == ID_POPUPMENU_EXIT) SendMessageW(hWnd, WM_CLOSE, NULL, NULL); if (idMenu == ID_POPUPMENU_EXIT) SendMessageW(hWnd, WM_CLOSE, NULL, NULL);
} }
}
break; break;
}
case WM_DESTROY: case WM_DESTROY:
{ {
PostQuitMessage(0); PostQuitMessage(0);
}
break; break;
}
default: default:
return DefWindowProcW(hWnd, message, wParam, lParam); return DefWindowProcW(hWnd, message, wParam, lParam);
@@ -498,11 +496,7 @@ INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
case WM_NOTIFY: case WM_NOTIFY:
{ {
LPNMHDR pNMHdr = (LPNMHDR)lParam; LPNMHDR pNMHdr = (LPNMHDR)lParam;
switch (pNMHdr->code) if ((NM_CLICK == pNMHdr->code || NM_RETURN == pNMHdr->code) && IDC_DONATIONLINK == pNMHdr->idFrom)
{
case NM_CLICK:
case NM_RETURN:
if (pNMHdr->idFrom == IDC_DONATIONLINK)
{ {
PNMLINK pNMLink = (PNMLINK)pNMHdr; PNMLINK pNMLink = (PNMLINK)pNMHdr;
LITEM item = pNMLink->item; LITEM item = pNMLink->item;
@@ -512,8 +506,6 @@ INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
} }
break; break;
} }
break;
}
case WM_COMMAND: case WM_COMMAND:
if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
@@ -521,8 +513,8 @@ INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
EndDialog(hDlg, LOWORD(wParam)); EndDialog(hDlg, LOWORD(wParam));
diag_log(L"Closing 'About' dialog"); diag_log(L"Closing 'About' dialog");
return (INT_PTR)TRUE; return (INT_PTR)TRUE;
break;
} }
break;
} }
return (INT_PTR)FALSE; return (INT_PTR)FALSE;
} }

Binary file not shown.