Clean up code.
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
// wCenterWindow, v2.3.2
|
// wCenterWindow
|
||||||
// Logger.cpp
|
// Logger.cpp
|
||||||
//
|
//
|
||||||
#include "framework.h"
|
#include "framework.h"
|
||||||
@@ -9,59 +9,53 @@
|
|||||||
std::wofstream logfile;
|
std::wofstream logfile;
|
||||||
extern WCHAR szTitle[];
|
extern WCHAR szTitle[];
|
||||||
extern LPVOID szBuffer;
|
extern LPVOID szBuffer;
|
||||||
namespace fs = std::filesystem;
|
|
||||||
|
|
||||||
std::wstring PrintTitle()
|
|
||||||
{
|
|
||||||
wchar_t szWinTitle[2048];
|
|
||||||
StringCchPrintf(szWinTitle, 2048, L"%s", szBuffer);
|
|
||||||
return szWinTitle;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::wstring GetTimeStamp()
|
std::wstring GetTimeStamp()
|
||||||
{
|
{
|
||||||
SYSTEMTIME lt;
|
SYSTEMTIME lt;
|
||||||
GetLocalTime(<);
|
GetLocalTime(<);
|
||||||
wchar_t ts[TS_LEN];
|
WCHAR ts[TS_LEN];
|
||||||
StringCchPrintfW(ts, TS_LEN, L"%d-%02d-%02d %02d:%02d:%02d.%03d - ", lt.wYear, lt.wMonth, lt.wDay, lt.wHour, lt.wMinute, lt.wSecond, lt.wMilliseconds);
|
StringCchPrintfW(ts, TS_LEN, L"%d-%02d-%02d %02d:%02d:%02d.%03d - ", lt.wYear, lt.wMonth, lt.wDay, lt.wHour, lt.wMinute, lt.wSecond, lt.wMilliseconds);
|
||||||
return ts;
|
return ts;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenLogFile()
|
void OpenLogFile()
|
||||||
{
|
{
|
||||||
wchar_t lpszPath[PATH_LEN]{};
|
WCHAR lpszPath[PATH_LEN] = { 0 };
|
||||||
DWORD dwPathLength = GetModuleFileNameW(NULL, lpszPath, PATH_LEN);
|
DWORD dwPathLength = GetModuleFileNameW(NULL, lpszPath, PATH_LEN);
|
||||||
DWORD dwError = GetLastError();
|
DWORD dwError = GetLastError();
|
||||||
if (ERROR_INSUFFICIENT_BUFFER == dwError)
|
if (ERROR_INSUFFICIENT_BUFFER == dwError)
|
||||||
{
|
{
|
||||||
MessageBoxW(NULL, L"Path to logfile is too long! Working without logging.", (LPCWSTR)szTitle, MB_OK | MB_ICONWARNING);
|
MessageBoxW(NULL, L"Path to logfile is too long! Working without logging", (LPCWSTR)szTitle, MB_OK | MB_ICONWARNING);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (NULL == dwPathLength)
|
if (NULL == dwPathLength)
|
||||||
{
|
{
|
||||||
MessageBoxW(NULL, L"Can't get module filename! Working without logging.", (LPCWSTR)szTitle, MB_OK | MB_ICONWARNING);
|
MessageBoxW(NULL, L"Can't get module filename! Working without logging", (LPCWSTR)szTitle, MB_OK | MB_ICONWARNING);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fs::path log_path = lpszPath;
|
std::filesystem::path log_path = lpszPath;
|
||||||
log_path.replace_extension(L".log");
|
log_path.replace_extension(L".log");
|
||||||
fs::path bak_path = log_path;
|
std::filesystem::path bak_path = log_path;
|
||||||
bak_path.replace_extension(L".bak");
|
bak_path.replace_extension(L".bak");
|
||||||
|
|
||||||
if (fs::exists(log_path)) fs::rename(log_path, bak_path);
|
if (std::filesystem::exists(log_path)) std::filesystem::rename(log_path, bak_path);
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
log_path = L"d:\\test.log";
|
log_path = L"d:\\test.log";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
logfile.open(log_path);
|
logfile.open(log_path);
|
||||||
if (logfile.is_open())
|
if (logfile.is_open())
|
||||||
{
|
{
|
||||||
diag_log(L"Start logging.");
|
diag_log(L"Start logging");
|
||||||
diag_log(L"Logfile:", log_path);
|
diag_log(L"Logfile:", log_path);
|
||||||
diag_log(log_path, L"successfully opened.");
|
diag_log(L"Log-file was successfully opened");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MessageBoxW(NULL, L"Can't open logfile! Working without logging.", (LPCWSTR)szTitle, MB_OK | MB_ICONWARNING);
|
MessageBoxW(NULL, L"Can't open logfile! Working without logging", (LPCWSTR)szTitle, MB_OK | MB_ICONWARNING);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -70,7 +64,7 @@ void CloseLogFile()
|
|||||||
{
|
{
|
||||||
if (logfile)
|
if (logfile)
|
||||||
{
|
{
|
||||||
diag_log(L"End logging.");
|
diag_log(L"End logging");
|
||||||
logfile.close();
|
logfile.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// wCenterWindow, v2.3.2
|
// wCenterWindow
|
||||||
// Logger.h
|
// Logger.h
|
||||||
//
|
//
|
||||||
#pragma once
|
#pragma once
|
||||||
@@ -6,7 +6,6 @@
|
|||||||
|
|
||||||
extern std::wofstream logfile;
|
extern std::wofstream logfile;
|
||||||
std::wstring GetTimeStamp();
|
std::wstring GetTimeStamp();
|
||||||
std::wstring PrintTitle();
|
|
||||||
|
|
||||||
template <typename T1>
|
template <typename T1>
|
||||||
void diag_log(T1 arg1)
|
void diag_log(T1 arg1)
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
// header.h : include file for standard system include files,
|
// wCenterWindow
|
||||||
// or project specific include files
|
// framework.h
|
||||||
//
|
//
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "targetver.h"
|
#include "targetver.h"
|
||||||
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
||||||
|
|
||||||
@@ -17,10 +15,5 @@
|
|||||||
#include <shellapi.h>
|
#include <shellapi.h>
|
||||||
#include <CommCtrl.h>
|
#include <CommCtrl.h>
|
||||||
|
|
||||||
// C RunTime Header Files
|
|
||||||
//#include <stdlib.h>
|
|
||||||
//#include <malloc.h>
|
|
||||||
//#include <memory.h>
|
|
||||||
|
|
||||||
// Project Specific Header Files
|
// Project Specific Header Files
|
||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
// wCenterWindow, v2.3.2
|
// wCenterWindow
|
||||||
//
|
//
|
||||||
// TODO: More verbose logs - partially done.
|
// TODO: More verbose logs - partially done.
|
||||||
// TODO: More verbose error messages
|
// TODO: More verbose error messages
|
||||||
// TODO: Window's title in logs (Impossible?)
|
// TODO: Window's title in logs
|
||||||
|
|
||||||
#include "framework.h"
|
#include "framework.h"
|
||||||
#include "wCenterWindow.h"
|
#include "wCenterWindow.h"
|
||||||
@@ -55,7 +55,7 @@ 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);
|
||||||
|
|
||||||
RECT fgwrc = { 0 };
|
RECT fgwrc = { 0 };
|
||||||
GetWindowRect(hwnd, &fgwrc);
|
GetWindowRect(hwnd, &fgwrc);
|
||||||
@@ -196,124 +196,121 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|||||||
{
|
{
|
||||||
switch (message)
|
switch (message)
|
||||||
{
|
{
|
||||||
case WM_CREATE:
|
case WM_CREATE:
|
||||||
{
|
|
||||||
hMenu = LoadMenuW(hInst, MAKEINTRESOURCE(IDR_MENU));
|
|
||||||
if (!hMenu)
|
|
||||||
{
|
{
|
||||||
diag_log(L"Loading context menu failed!");
|
hMenu = LoadMenuW(hInst, MAKEINTRESOURCE(IDR_MENU));
|
||||||
ShowError(IDS_ERR_MENU);
|
if (!hMenu)
|
||||||
SendMessageW(hWnd, WM_CLOSE, NULL, NULL);
|
|
||||||
}
|
|
||||||
diag_log(L"Context menu successfully loaded");
|
|
||||||
|
|
||||||
hPopup = GetSubMenu(hMenu, 0);
|
|
||||||
if (!hPopup)
|
|
||||||
{
|
|
||||||
diag_log(L"Creating popup menu failed!");
|
|
||||||
ShowError(IDS_ERR_POPUP);
|
|
||||||
SendMessageW(hWnd, WM_CLOSE, NULL, NULL);
|
|
||||||
}
|
|
||||||
diag_log(L"Popup menu successfully created");
|
|
||||||
|
|
||||||
mii.cbSize = sizeof(MENUITEMINFO);
|
|
||||||
mii.fMask = MIIM_STATE;
|
|
||||||
bWorkArea ? mii.fState = MFS_CHECKED : mii.fState = MFS_UNCHECKED;
|
|
||||||
SetMenuItemInfoW(hPopup, ID_POPUPMENU_AREA, FALSE, &mii);
|
|
||||||
|
|
||||||
//nid.cbSize = sizeof(NOTIFYICONDATAW);
|
|
||||||
nid.cbSize = sizeof(nid);
|
|
||||||
nid.hWnd = hWnd;
|
|
||||||
//nid.uVersion = NOTIFYICON_VERSION_4;
|
|
||||||
nid.uVersion = NOTIFYICON_VERSION;
|
|
||||||
nid.uCallbackMessage = WM_WCW;
|
|
||||||
nid.hIcon = hIcon;
|
|
||||||
nid.uID = IDI_TRAYICON;
|
|
||||||
nid.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP;
|
|
||||||
nid.dwInfoFlags = NIIF_NONE;
|
|
||||||
nid.dwState = NIS_HIDDEN;
|
|
||||||
nid.dwStateMask = NIS_HIDDEN;
|
|
||||||
//StringCchCopyW(nid.szTip, _countof(nid.szTip), szTitle);
|
|
||||||
StringCchCopyW(nid.szTip, ARRAYSIZE(nid.szTip), szTitle);
|
|
||||||
|
|
||||||
hMouseHook = SetWindowsHookExW(WH_MOUSE_LL, MouseHookProc, hInst, NULL);
|
|
||||||
if (!hMouseHook)
|
|
||||||
{
|
|
||||||
diag_log(L"Creating mouse hook failed!");
|
|
||||||
ShowError(IDS_ERR_HOOK);
|
|
||||||
SendMessageW(hWnd, WM_CLOSE, NULL, NULL);
|
|
||||||
}
|
|
||||||
diag_log(L"Mouse hook was successfully set");
|
|
||||||
|
|
||||||
hKbdHook = SetWindowsHookExW(WH_KEYBOARD_LL, KeyboardHookProc, hInst, NULL);
|
|
||||||
if (!hKbdHook)
|
|
||||||
{
|
|
||||||
diag_log(L"Creating keyboard hook failed!");
|
|
||||||
ShowError(IDS_ERR_HOOK);
|
|
||||||
SendMessageW(hWnd, WM_CLOSE, NULL, NULL);
|
|
||||||
}
|
|
||||||
diag_log(L"Keyboard hook was successfully set");
|
|
||||||
|
|
||||||
LoadStringW(hInst, IDS_ABOUT, szAbout, _countof(szAbout));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case WM_WCW:
|
|
||||||
{
|
|
||||||
if ((lParam == WM_RBUTTONDOWN || lParam == WM_LBUTTONDOWN) && wParam == IDI_TRAYICON)
|
|
||||||
{
|
|
||||||
SetForegroundWindow(hWnd);
|
|
||||||
POINT pt;
|
|
||||||
GetCursorPos(&pt);
|
|
||||||
int idMenu = TrackPopupMenu(hPopup, TPM_RETURNCMD, pt.x, pt.y, 0, hWnd, NULL);
|
|
||||||
if (idMenu == ID_POPUPMENU_ICON)
|
|
||||||
{
|
{
|
||||||
bShowIcon = FALSE;
|
diag_log(L"Loading context menu failed!");
|
||||||
HandlingTrayIcon();
|
ShowError(IDS_ERR_MENU);
|
||||||
|
SendMessageW(hWnd, WM_CLOSE, NULL, NULL);
|
||||||
}
|
}
|
||||||
if (idMenu == ID_POPUPMENU_AREA)
|
diag_log(L"Context menu successfully loaded");
|
||||||
|
|
||||||
|
hPopup = GetSubMenu(hMenu, 0);
|
||||||
|
if (!hPopup)
|
||||||
{
|
{
|
||||||
bWorkArea = !bWorkArea;
|
diag_log(L"Creating popup menu failed!");
|
||||||
bWorkArea ? mii.fState = MFS_CHECKED : mii.fState = MFS_UNCHECKED;
|
ShowError(IDS_ERR_POPUP);
|
||||||
SetMenuItemInfoW(hPopup, ID_POPUPMENU_AREA, FALSE, &mii);
|
SendMessageW(hWnd, WM_CLOSE, NULL, NULL);
|
||||||
diag_log(L"Changed 'Use workarea' option to", bWorkArea);
|
|
||||||
}
|
}
|
||||||
if (idMenu == ID_POPUPMENU_ABOUT && !bKPressed)
|
diag_log(L"Popup menu successfully created");
|
||||||
|
|
||||||
|
mii.cbSize = sizeof(MENUITEMINFO);
|
||||||
|
mii.fMask = MIIM_STATE;
|
||||||
|
bWorkArea ? mii.fState = MFS_CHECKED : mii.fState = MFS_UNCHECKED;
|
||||||
|
SetMenuItemInfoW(hPopup, ID_POPUPMENU_AREA, FALSE, &mii);
|
||||||
|
|
||||||
|
nid.cbSize = sizeof(NOTIFYICONDATAW);
|
||||||
|
nid.hWnd = hWnd;
|
||||||
|
nid.uVersion = NOTIFYICON_VERSION;
|
||||||
|
nid.uCallbackMessage = WM_WCW;
|
||||||
|
nid.hIcon = hIcon;
|
||||||
|
nid.uID = IDI_TRAYICON;
|
||||||
|
nid.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP;
|
||||||
|
nid.dwInfoFlags = NIIF_NONE;
|
||||||
|
nid.dwState = NIS_HIDDEN;
|
||||||
|
nid.dwStateMask = NIS_HIDDEN;
|
||||||
|
StringCchCopyW(nid.szTip, _countof(nid.szTip), szTitle);
|
||||||
|
|
||||||
|
hMouseHook = SetWindowsHookExW(WH_MOUSE_LL, MouseHookProc, hInst, NULL);
|
||||||
|
if (!hMouseHook)
|
||||||
{
|
{
|
||||||
bKPressed = TRUE;
|
diag_log(L"Creating mouse hook failed!");
|
||||||
diag_log(L"Opening 'About' dialog");
|
ShowError(IDS_ERR_HOOK);
|
||||||
DialogBoxW(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, (DLGPROC)About);
|
SendMessageW(hWnd, WM_CLOSE, NULL, NULL);
|
||||||
bKPressed = FALSE;
|
|
||||||
}
|
}
|
||||||
if (idMenu == ID_POPUPMENU_EXIT) SendMessageW(hWnd, WM_CLOSE, NULL, NULL);
|
diag_log(L"Mouse hook was successfully set");
|
||||||
|
|
||||||
|
hKbdHook = SetWindowsHookExW(WH_KEYBOARD_LL, KeyboardHookProc, hInst, NULL);
|
||||||
|
if (!hKbdHook)
|
||||||
|
{
|
||||||
|
diag_log(L"Creating keyboard hook failed!");
|
||||||
|
ShowError(IDS_ERR_HOOK);
|
||||||
|
SendMessageW(hWnd, WM_CLOSE, NULL, NULL);
|
||||||
|
}
|
||||||
|
diag_log(L"Keyboard hook was successfully set");
|
||||||
|
|
||||||
|
LoadStringW(hInst, IDS_ABOUT, szAbout, _countof(szAbout));
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case WM_QUERYENDSESSION:
|
case WM_WCW:
|
||||||
{
|
{
|
||||||
diag_log(L"Recieved WM_QUERYENDSESSION message, lParam =", lParam);
|
if (IDI_TRAYICON == wParam && (WM_RBUTTONDOWN == lParam || WM_LBUTTONDOWN == lParam))
|
||||||
CloseLogFile();
|
{
|
||||||
return TRUE;
|
SetForegroundWindow(hWnd);
|
||||||
break;
|
POINT pt;
|
||||||
}
|
GetCursorPos(&pt);
|
||||||
|
int idMenu = TrackPopupMenu(hPopup, TPM_RETURNCMD, pt.x, pt.y, 0, hWnd, NULL);
|
||||||
|
if (ID_POPUPMENU_ICON == idMenu)
|
||||||
|
{
|
||||||
|
bShowIcon = FALSE;
|
||||||
|
HandlingTrayIcon();
|
||||||
|
}
|
||||||
|
if (ID_POPUPMENU_AREA == idMenu)
|
||||||
|
{
|
||||||
|
bWorkArea = !bWorkArea;
|
||||||
|
bWorkArea ? mii.fState = MFS_CHECKED : mii.fState = MFS_UNCHECKED;
|
||||||
|
SetMenuItemInfoW(hPopup, ID_POPUPMENU_AREA, FALSE, &mii);
|
||||||
|
diag_log(L"Changed 'Use workarea' option to", bWorkArea);
|
||||||
|
}
|
||||||
|
if (ID_POPUPMENU_ABOUT == idMenu && !bKPressed)
|
||||||
|
{
|
||||||
|
bKPressed = TRUE;
|
||||||
|
diag_log(L"Opening 'About' dialog");
|
||||||
|
DialogBoxW(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, (DLGPROC)About);
|
||||||
|
bKPressed = FALSE;
|
||||||
|
}
|
||||||
|
if (ID_POPUPMENU_EXIT == idMenu) SendMessageW(hWnd, WM_CLOSE, NULL, NULL);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case WM_DESTROY:
|
case WM_QUERYENDSESSION:
|
||||||
{
|
{
|
||||||
PostQuitMessage(0);
|
diag_log(L"Recieved WM_QUERYENDSESSION message, lParam =", lParam);
|
||||||
}
|
CloseLogFile();
|
||||||
break;
|
return TRUE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
case WM_DESTROY:
|
||||||
return DefWindowProcW(hWnd, message, wParam, lParam);
|
{
|
||||||
|
PostQuitMessage(0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
return DefWindowProcW(hWnd, message, wParam, lParam);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
LRESULT CALLBACK MouseHookProc(int nCode, WPARAM wParam, LPARAM lParam)
|
LRESULT CALLBACK MouseHookProc(int nCode, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
if (wParam == WM_MBUTTONUP) bMPressed = FALSE;
|
if (WM_MBUTTONUP == wParam) bMPressed = FALSE;
|
||||||
if (wParam == WM_MBUTTONDOWN && bLCTRL && bLWIN && !bMPressed)
|
if (WM_MBUTTONDOWN == wParam && bLCTRL && bLWIN && !bMPressed)
|
||||||
{
|
{
|
||||||
diag_log(L"Pressed LCTRL + LWIN + MMB");
|
diag_log(L"Pressed LCTRL + LWIN + MMB");
|
||||||
bMPressed = TRUE;
|
bMPressed = TRUE;
|
||||||
@@ -329,19 +326,19 @@ LRESULT CALLBACK KeyboardHookProc(int nCode, WPARAM wParam, LPARAM lParam)
|
|||||||
{
|
{
|
||||||
pkhs = (KBDLLHOOKSTRUCT*)lParam;
|
pkhs = (KBDLLHOOKSTRUCT*)lParam;
|
||||||
|
|
||||||
if (wParam == WM_KEYUP)
|
if (WM_KEYUP == wParam)
|
||||||
{
|
{
|
||||||
if (pkhs->vkCode == VK_LCONTROL) bLCTRL = FALSE;
|
if (VK_LCONTROL == pkhs->vkCode) bLCTRL = FALSE;
|
||||||
if (pkhs->vkCode == VK_LWIN) bLWIN = FALSE;
|
if (VK_LWIN == pkhs->vkCode) bLWIN = FALSE;
|
||||||
bKPressed = FALSE;
|
bKPressed = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wParam == WM_KEYDOWN)
|
if (WM_KEYDOWN == wParam)
|
||||||
{
|
{
|
||||||
if (pkhs->vkCode == VK_LCONTROL) bLCTRL = TRUE;
|
if (VK_LCONTROL == pkhs->vkCode) bLCTRL = TRUE;
|
||||||
if (pkhs->vkCode == VK_LWIN) bLWIN = TRUE;
|
if (VK_LWIN == pkhs->vkCode) bLWIN = TRUE;
|
||||||
|
|
||||||
if (bLCTRL && bLWIN && pkhs->vkCode == KEY_I && !bKPressed) // 'I' key
|
if (KEY_I == pkhs->vkCode && bLCTRL && bLWIN && !bKPressed) // 'I' key
|
||||||
{
|
{
|
||||||
diag_log(L"Pressed LCTRL + LWIN + I");
|
diag_log(L"Pressed LCTRL + LWIN + I");
|
||||||
bKPressed = TRUE;
|
bKPressed = TRUE;
|
||||||
@@ -350,7 +347,7 @@ LRESULT CALLBACK KeyboardHookProc(int nCode, WPARAM wParam, LPARAM lParam)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bLCTRL && bLWIN && pkhs->vkCode == KEY_C && !bKPressed && !bKEYV) // 'C' key
|
if (KEY_C == pkhs->vkCode && bLCTRL && bLWIN && !bKPressed && !bKEYV) // 'C' key
|
||||||
{
|
{
|
||||||
diag_log(L"Pressed LCTRL + LWIN + C");
|
diag_log(L"Pressed LCTRL + LWIN + C");
|
||||||
bKPressed = TRUE;
|
bKPressed = TRUE;
|
||||||
@@ -361,7 +358,7 @@ LRESULT CALLBACK KeyboardHookProc(int nCode, WPARAM wParam, LPARAM lParam)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bLCTRL && bLWIN && pkhs->vkCode == KEY_V && !bKPressed && !bKEYV) // 'V' key
|
if (KEY_V == pkhs->vkCode && bLCTRL && bLWIN && !bKPressed && !bKEYV) // 'V' key
|
||||||
{
|
{
|
||||||
diag_log(L"Pressed LCTRL + LWIN + V");
|
diag_log(L"Pressed LCTRL + LWIN + V");
|
||||||
bKPressed = TRUE; bKEYV = TRUE;
|
bKPressed = TRUE; bKEYV = TRUE;
|
||||||
@@ -386,48 +383,49 @@ BOOL CALLBACK DlgProc(HWND hDlg, UINT dlgmsg, WPARAM wParam, LPARAM lParam)
|
|||||||
int x, y, w, h;
|
int x, y, w, h;
|
||||||
switch (dlgmsg)
|
switch (dlgmsg)
|
||||||
{
|
{
|
||||||
case WM_INITDIALOG:
|
case WM_INITDIALOG:
|
||||||
{
|
|
||||||
SetWindowTextW(hDlg, szTitle);
|
|
||||||
GetWindowTextW(hFgWnd, szWinTitle, _countof(szWinTitle));
|
|
||||||
GetClassNameW(hFgWnd, szWinClass, _countof(szWinClass));
|
|
||||||
GetWindowRect(hFgWnd, &rcFW);
|
|
||||||
x = rcFW.left;
|
|
||||||
y = rcFW.top;
|
|
||||||
w = rcFW.right - rcFW.left;
|
|
||||||
h = rcFW.bottom - rcFW.top;
|
|
||||||
SetDlgItemInt(hDlg, IDC_EDIT_X, x, TRUE);
|
|
||||||
SetDlgItemInt(hDlg, IDC_EDIT_Y, y, TRUE);
|
|
||||||
SetDlgItemInt(hDlg, IDC_EDIT_WIDTH, w, FALSE);
|
|
||||||
SetDlgItemInt(hDlg, IDC_EDIT_HEIGHT, h, FALSE);
|
|
||||||
SetDlgItemTextW(hDlg, IDC_EDIT_TITLE, szWinTitle);
|
|
||||||
SetDlgItemTextW(hDlg, IDC_EDIT_CLASS, szWinClass);
|
|
||||||
UpdateWindow(hDlg);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case WM_COMMAND:
|
|
||||||
switch (LOWORD(wParam))
|
|
||||||
{
|
{
|
||||||
case IDC_BUTTON_SET:
|
SetWindowTextW(hDlg, szTitle);
|
||||||
{
|
GetWindowTextW(hFgWnd, szWinTitle, _countof(szWinTitle));
|
||||||
x = GetDlgItemInt(hDlg, IDC_EDIT_X, NULL, TRUE);
|
GetClassNameW(hFgWnd, szWinClass, _countof(szWinClass));
|
||||||
y = GetDlgItemInt(hDlg, IDC_EDIT_Y, NULL, TRUE);
|
GetWindowRect(hFgWnd, &rcFW);
|
||||||
w = GetDlgItemInt(hDlg, IDC_EDIT_WIDTH, NULL, FALSE);
|
x = rcFW.left;
|
||||||
h = GetDlgItemInt(hDlg, IDC_EDIT_HEIGHT, NULL, FALSE);
|
y = rcFW.top;
|
||||||
SendMessageW(hFgWnd, WM_ENTERSIZEMOVE, NULL, NULL);
|
w = rcFW.right - rcFW.left;
|
||||||
MoveWindow(hFgWnd, x, y, w, h, TRUE);
|
h = rcFW.bottom - rcFW.top;
|
||||||
SendMessageW(hFgWnd, WM_EXITSIZEMOVE, NULL, NULL);
|
SetDlgItemInt(hDlg, IDC_EDIT_X, x, TRUE);
|
||||||
return TRUE;
|
SetDlgItemInt(hDlg, IDC_EDIT_Y, y, TRUE);
|
||||||
|
SetDlgItemInt(hDlg, IDC_EDIT_WIDTH, w, FALSE);
|
||||||
|
SetDlgItemInt(hDlg, IDC_EDIT_HEIGHT, h, FALSE);
|
||||||
|
SetDlgItemTextW(hDlg, IDC_EDIT_TITLE, szWinTitle);
|
||||||
|
SetDlgItemTextW(hDlg, IDC_EDIT_CLASS, szWinClass);
|
||||||
|
UpdateWindow(hDlg);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case IDCANCEL:
|
|
||||||
case IDC_BUTTON_CLOSE:
|
case WM_COMMAND:
|
||||||
{
|
switch (LOWORD(wParam))
|
||||||
EndDialog(hDlg, LOWORD(wParam));
|
{
|
||||||
diag_log(L"Closing 'Manual editing' dialog");
|
case IDC_BUTTON_SET:
|
||||||
break;
|
{
|
||||||
}
|
x = GetDlgItemInt(hDlg, IDC_EDIT_X, NULL, TRUE);
|
||||||
}
|
y = GetDlgItemInt(hDlg, IDC_EDIT_Y, NULL, TRUE);
|
||||||
|
w = GetDlgItemInt(hDlg, IDC_EDIT_WIDTH, NULL, FALSE);
|
||||||
|
h = GetDlgItemInt(hDlg, IDC_EDIT_HEIGHT, NULL, FALSE);
|
||||||
|
SendMessageW(hFgWnd, WM_ENTERSIZEMOVE, NULL, NULL);
|
||||||
|
MoveWindow(hFgWnd, x, y, w, h, TRUE);
|
||||||
|
SendMessageW(hFgWnd, WM_EXITSIZEMOVE, NULL, NULL);
|
||||||
|
return TRUE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case IDCANCEL:
|
||||||
|
case IDC_BUTTON_CLOSE:
|
||||||
|
{
|
||||||
|
EndDialog(hDlg, LOWORD(wParam));
|
||||||
|
diag_log(L"Closing 'Manual editing' dialog");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@@ -484,7 +482,7 @@ VOID ShowError(UINT uID)
|
|||||||
{
|
{
|
||||||
WCHAR szErrorText[MAX_LOADSTRING]; // Error's text
|
WCHAR szErrorText[MAX_LOADSTRING]; // Error's text
|
||||||
LoadStringW(hInst, uID, szErrorText, _countof(szErrorText));
|
LoadStringW(hInst, uID, szErrorText, _countof(szErrorText));
|
||||||
MessageBoxW(hWnd, szErrorText, szTitle, MB_OK | MB_ICONERROR | MB_TOPMOST);
|
MessageBoxW(NULL, szErrorText, szTitle, MB_OK | MB_ICONERROR | MB_TOPMOST);
|
||||||
}
|
}
|
||||||
|
|
||||||
INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
@@ -496,21 +494,17 @@ INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
|||||||
|
|
||||||
switch (message)
|
switch (message)
|
||||||
{
|
{
|
||||||
case WM_INITDIALOG:
|
case WM_INITDIALOG:
|
||||||
{
|
|
||||||
SetDlgItemTextW(hDlg, IDC_ABOUTHELP, szAbout);
|
|
||||||
return (INT_PTR)TRUE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case WM_NOTIFY:
|
|
||||||
{
|
|
||||||
LPNMHDR pNMHdr = (LPNMHDR)lParam;
|
|
||||||
switch (pNMHdr->code)
|
|
||||||
{
|
{
|
||||||
case NM_CLICK:
|
SetDlgItemTextW(hDlg, IDC_ABOUTHELP, szAbout);
|
||||||
case NM_RETURN:
|
return (INT_PTR)TRUE;
|
||||||
if (pNMHdr->idFrom == IDC_DONATIONLINK)
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case WM_NOTIFY:
|
||||||
|
{
|
||||||
|
LPNMHDR pNMHdr = (LPNMHDR)lParam;
|
||||||
|
if ((NM_CLICK == pNMHdr->code || NM_RETURN == pNMHdr->code) && IDC_DONATIONLINK == pNMHdr->idFrom)
|
||||||
{
|
{
|
||||||
PNMLINK pNMLink = (PNMLINK)pNMHdr;
|
PNMLINK pNMLink = (PNMLINK)pNMHdr;
|
||||||
LITEM item = pNMLink->item;
|
LITEM item = pNMLink->item;
|
||||||
@@ -520,15 +514,15 @@ 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)
|
|
||||||
{
|
{
|
||||||
EndDialog(hDlg, LOWORD(wParam));
|
if (IDOK == LOWORD(wParam) || IDCANCEL == LOWORD(wParam))
|
||||||
diag_log(L"Closing 'About' dialog");
|
{
|
||||||
return (INT_PTR)TRUE;
|
EndDialog(hDlg, LOWORD(wParam));
|
||||||
|
diag_log(L"Closing 'About' dialog");
|
||||||
|
return (INT_PTR)TRUE;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
// wCenterWindow
|
||||||
|
// wCenterWindow.h
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
|
|||||||
@@ -13,11 +13,11 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<dependentAssembly>
|
<dependentAssembly>
|
||||||
<assemblyIdentity
|
<assemblyIdentity
|
||||||
type="Win32"
|
type="Win32"
|
||||||
name="Microsoft.Windows.Common-Controls"
|
name="Microsoft.Windows.Common-Controls"
|
||||||
version="6.0.0.0"
|
version="6.0.0.0"
|
||||||
publicKeyToken="6595b64144ccf1df"
|
publicKeyToken="6595b64144ccf1df"
|
||||||
language="*"
|
language="*"
|
||||||
processorArchitecture="*"/>
|
processorArchitecture="*"/>
|
||||||
</dependentAssembly>
|
</dependentAssembly>
|
||||||
</dependency>
|
</dependency>
|
||||||
@@ -32,7 +32,7 @@
|
|||||||
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
|
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
|
||||||
<!--ID Windows 8.1 -->
|
<!--ID Windows 8.1 -->
|
||||||
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
|
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
|
||||||
<!--ID Windows 10 -->
|
<!--ID Windows 10/11 -->
|
||||||
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
|
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
|
||||||
</application>
|
</application>
|
||||||
</compatibility>
|
</compatibility>
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user