Compare commits
19 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ba18587c31 | |||
| c6d9f908e5 | |||
| 8fbd6f1bde | |||
| 7c73a52f0a | |||
| 05c4ad977b | |||
| c968b47baf | |||
| 6f6ce164ee | |||
| 7cd58a9a15 | |||
| d5b3ef1040 | |||
| 76099356cd | |||
| 750ac44696 | |||
| 0a0fe05555 | |||
| b6a0f9a3c5 | |||
| e7c06ec4b6 | |||
| f58e6a99cb | |||
| b5e040f3d5 | |||
| fee7025323 | |||
|
|
6c9855ab38 | ||
|
|
3f438f6038 |
@@ -1,4 +1,4 @@
|
||||
// wCenterWindow, v2.3.2
|
||||
// wCenterWindow, v2.3.3
|
||||
// Logger.cpp
|
||||
//
|
||||
#include "framework.h"
|
||||
@@ -11,13 +11,15 @@ extern WCHAR szTitle[];
|
||||
extern LPVOID szBuffer;
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
std::wstring PrintTitle() {
|
||||
std::wstring PrintTitle()
|
||||
{
|
||||
wchar_t szWinTitle[2048];
|
||||
StringCchPrintf(szWinTitle, 2048, L"%s", szBuffer);
|
||||
return szWinTitle;
|
||||
}
|
||||
|
||||
std::wstring GetTimeStamp() {
|
||||
std::wstring GetTimeStamp()
|
||||
{
|
||||
SYSTEMTIME lt;
|
||||
GetLocalTime(<);
|
||||
wchar_t ts[TS_LEN];
|
||||
@@ -25,15 +27,18 @@ std::wstring GetTimeStamp() {
|
||||
return ts;
|
||||
}
|
||||
|
||||
void OpenLogFile() {
|
||||
void OpenLogFile()
|
||||
{
|
||||
wchar_t lpszPath[PATH_LEN]{};
|
||||
DWORD dwPathLength = GetModuleFileNameW(NULL, lpszPath, PATH_LEN);
|
||||
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);
|
||||
return;
|
||||
}
|
||||
if (NULL == dwPathLength) {
|
||||
if (NULL == dwPathLength)
|
||||
{
|
||||
MessageBoxW(NULL, L"Can't get module filename! Working without logging.", (LPCWSTR)szTitle, MB_OK | MB_ICONWARNING);
|
||||
return;
|
||||
}
|
||||
@@ -48,18 +53,23 @@ void OpenLogFile() {
|
||||
log_path = L"d:\\test.log";
|
||||
#endif
|
||||
logfile.open(log_path);
|
||||
if (logfile.is_open()) {
|
||||
if (logfile.is_open())
|
||||
{
|
||||
diag_log(L"Start logging.");
|
||||
diag_log(L"Logfile:", log_path);
|
||||
diag_log(log_path, L"successfully opened.");
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBoxW(NULL, L"Can't open logfile! Working without logging.", (LPCWSTR)szTitle, MB_OK | MB_ICONWARNING);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void CloseLogFile() {
|
||||
if (logfile) {
|
||||
void CloseLogFile()
|
||||
{
|
||||
if (logfile)
|
||||
{
|
||||
diag_log(L"End logging.");
|
||||
logfile.close();
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// wCenterWindow, v2.3.2
|
||||
// wCenterWindow, v2.3.3
|
||||
// Logger.h
|
||||
//
|
||||
#pragma once
|
||||
@@ -9,46 +9,50 @@ std::wstring GetTimeStamp();
|
||||
std::wstring PrintTitle();
|
||||
|
||||
template <typename T1>
|
||||
void diag_log(T1 arg1) {
|
||||
void diag_log(T1 arg1)
|
||||
{
|
||||
logfile << GetTimeStamp() << arg1 << std::endl;
|
||||
}
|
||||
|
||||
template <typename T1, typename T2>
|
||||
void diag_log(T1 arg1, T2 arg2) {
|
||||
void diag_log(T1 arg1, T2 arg2)
|
||||
{
|
||||
logfile << GetTimeStamp() << arg1 << ' ' << arg2 << std::endl;
|
||||
}
|
||||
|
||||
template <typename T1, typename T2, typename T3>
|
||||
void diag_log(T1 arg1, T2 arg2, T3 arg3) {
|
||||
void diag_log(T1 arg1, T2 arg2, T3 arg3)
|
||||
{
|
||||
logfile << GetTimeStamp() << arg1 << ' ' << arg2 << ' ' << arg3 << std::endl;
|
||||
}
|
||||
|
||||
template <typename T1, typename T2, typename T3, typename T4>
|
||||
void diag_log(T1 arg1, T2 arg2, T3 arg3, T4 arg4) {
|
||||
//if (typeid(T4) == typeid(WCHAR)) {
|
||||
// logfile << GetTimeStamp() << arg1 << ' ' << arg2 << ' ' << arg3 << ' ' << PrintTitle() << std::endl;
|
||||
// return;
|
||||
//}
|
||||
void diag_log(T1 arg1, T2 arg2, T3 arg3, T4 arg4)
|
||||
{
|
||||
logfile << GetTimeStamp() << arg1 << ' ' << arg2 << ' ' << arg3 << ' ' << arg4 << std::endl;
|
||||
}
|
||||
|
||||
template <typename T1, typename T2, typename T3, typename T4, typename T5>
|
||||
void diag_log(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5) {
|
||||
void diag_log(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5)
|
||||
{
|
||||
logfile << GetTimeStamp() << arg1 << ' ' << arg2 << ' ' << arg3 << ' ' << arg4 << ' ' << arg5 << std::endl;
|
||||
}
|
||||
|
||||
template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
|
||||
void diag_log(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6) {
|
||||
void diag_log(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6)
|
||||
{
|
||||
logfile << GetTimeStamp() << arg1 << ' ' << arg2 << ' ' << arg3 << ' ' << arg4 << ' ' << arg5 << ' ' << arg6 << std::endl;
|
||||
}
|
||||
|
||||
template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7>
|
||||
void diag_log(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7) {
|
||||
void diag_log(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7)
|
||||
{
|
||||
logfile << GetTimeStamp() << arg1 << ' ' << arg2 << ' ' << arg3 << ' ' << arg4 << ' ' << arg5 << ' ' << arg6 << ' ' << arg7 << std::endl;
|
||||
}
|
||||
|
||||
template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8>
|
||||
void diag_log(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8) {
|
||||
void diag_log(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8)
|
||||
{
|
||||
logfile << GetTimeStamp() << arg1 << ' ' << arg2 << ' ' << arg3 << ' ' << arg4 << ' ' << arg5 << ' ' << arg6 << ' ' << arg7 << ' ' << arg8 << std::endl;
|
||||
}
|
||||
|
||||
|
||||
BIN
wCenterWindow/VersionInfo.rc
Normal file
BIN
wCenterWindow/VersionInfo.rc
Normal file
Binary file not shown.
@@ -5,7 +5,8 @@
|
||||
#pragma once
|
||||
|
||||
#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
|
||||
|
||||
// Windows Header Files
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
@@ -13,6 +14,7 @@
|
||||
#include <string>
|
||||
#include <strsafe.h>
|
||||
#include <windows.h>
|
||||
#include <shellapi.h>
|
||||
#include <CommCtrl.h>
|
||||
|
||||
// C RunTime Header Files
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// wCenterWindow, v2.3.2
|
||||
// wCenterWindow, v2.3.3
|
||||
//
|
||||
// TODO: More verbose logs - partially done.
|
||||
// TODO: More verbose error messages
|
||||
@@ -32,12 +32,15 @@ BOOL bKPressed = FALSE, bMPressed = FALSE, bShowIcon = TRUE, bWorkArea = TRUE
|
||||
BOOL bLCTRL = FALSE, bLWIN = FALSE, bKEYV = FALSE;
|
||||
|
||||
RECT rcFW = { 0 };
|
||||
NOTIFYICONDATA nid = { 0 };
|
||||
LPKBDLLHOOKSTRUCT pkhs;
|
||||
MENUITEMINFO mii;
|
||||
NOTIFYICONDATAW nid = { 0 };
|
||||
LPKBDLLHOOKSTRUCT pkhs = { 0 };
|
||||
MENUITEMINFO mii = { 0 };
|
||||
|
||||
LPVOID szBuffer;
|
||||
|
||||
// {2D7B7F30-4B5F-4380-9807-57D7A2E37F6C}
|
||||
static const GUID guid = { 0x2d7b7f30, 0x4b5f, 0x4380, { 0x98, 0x7, 0x57, 0xd7, 0xa2, 0xe3, 0x7f, 0x6c } };
|
||||
|
||||
// Forward declarations of functions included in this code module:
|
||||
VOID HandlingTrayIcon();
|
||||
VOID ShowError(UINT);
|
||||
@@ -50,35 +53,22 @@ INT_PTR CALLBACK About(HWND, UINT, WPARAM, LPARAM);
|
||||
|
||||
|
||||
|
||||
ATOM MyRegisterClass(HINSTANCE hInstance)
|
||||
{
|
||||
WNDCLASSEX wcex = { 0 };
|
||||
wcex.cbSize = sizeof(WNDCLASSEX);
|
||||
wcex.lpfnWndProc = WndProc;
|
||||
wcex.hInstance = hInstance;
|
||||
wcex.hIcon = LoadIconW(hInstance, MAKEINTRESOURCE(IDI_TRAYICON));
|
||||
wcex.hCursor = LoadCursorW(nullptr, IDC_ARROW);
|
||||
wcex.lpszClassName = szClass;
|
||||
wcex.hIconSm = wcex.hIcon;
|
||||
hIcon = wcex.hIcon;
|
||||
return RegisterClassExW(&wcex);
|
||||
}
|
||||
|
||||
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;
|
||||
RECT fgwrc = { 0 };
|
||||
GetWindowRect(hwnd, &fgwrc);
|
||||
LONG nWidth = fgwrc.right - fgwrc.left;
|
||||
LONG nHeight = fgwrc.bottom - fgwrc.top;
|
||||
|
||||
diag_log(L"Moving window from x =", fgwrc.left, L"y =", fgwrc.top);
|
||||
|
||||
MONITORINFO mi;
|
||||
MONITORINFO mi = { 0 };
|
||||
mi.cbSize = sizeof(MONITORINFO);
|
||||
GetMonitorInfoW(MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST), &mi);
|
||||
RECT area;
|
||||
RECT area = { 0 };
|
||||
if (bWorkArea)
|
||||
{
|
||||
area.bottom = mi.rcWork.bottom;
|
||||
@@ -112,6 +102,20 @@ VOID MoveWindowToMonitorCenter(HWND hwnd, BOOL bWorkArea, BOOL bResize)
|
||||
}
|
||||
|
||||
|
||||
ATOM MyRegisterClass(HINSTANCE hInstance)
|
||||
{
|
||||
WNDCLASSEX wcex = { 0 };
|
||||
wcex.cbSize = sizeof(WNDCLASSEX);
|
||||
wcex.lpfnWndProc = WndProc;
|
||||
wcex.hInstance = hInstance;
|
||||
wcex.hIcon = LoadIconW(hInstance, MAKEINTRESOURCE(IDI_TRAYICON));
|
||||
wcex.hCursor = LoadCursorW(nullptr, IDC_ARROW);
|
||||
wcex.lpszClassName = szClass;
|
||||
wcex.hIconSm = wcex.hIcon;
|
||||
hIcon = wcex.hIcon;
|
||||
return RegisterClassExW(&wcex);
|
||||
}
|
||||
|
||||
|
||||
int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow)
|
||||
{
|
||||
@@ -133,7 +137,7 @@ int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmd
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
ShowError(IDS_ERR_WND);
|
||||
@@ -143,8 +147,8 @@ int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmd
|
||||
int nArgs = 0;
|
||||
LPWSTR* szArglist = CommandLineToArgvW(GetCommandLineW(), &nArgs);
|
||||
|
||||
diag_log(L"Arguments:", nArgs);
|
||||
for (int i = 0; i < nArgs; i++)
|
||||
diag_log(L"Arguments:", nArgs - 1);
|
||||
for (int i = 1; i < nArgs; i++)
|
||||
{
|
||||
diag_log(L"Argument", i, L":", szArglist[i]);
|
||||
}
|
||||
@@ -193,103 +197,105 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (message)
|
||||
{
|
||||
case WM_CREATE:
|
||||
{
|
||||
hMenu = LoadMenuW(hInst, MAKEINTRESOURCE(IDR_MENU));
|
||||
if (!hMenu)
|
||||
case WM_CREATE:
|
||||
{
|
||||
diag_log(L"Loading context menu failed!");
|
||||
ShowError(IDS_ERR_MENU);
|
||||
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(NOTIFYICONDATA);
|
||||
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_INFO;
|
||||
StringCchCopyW(nid.szTip, _countof(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)
|
||||
hMenu = LoadMenuW(hInst, MAKEINTRESOURCE(IDR_MENU));
|
||||
if (!hMenu)
|
||||
{
|
||||
bShowIcon = FALSE;
|
||||
HandlingTrayIcon();
|
||||
diag_log(L"Loading context menu failed!");
|
||||
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;
|
||||
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);
|
||||
diag_log(L"Creating popup menu failed!");
|
||||
ShowError(IDS_ERR_POPUP);
|
||||
SendMessageW(hWnd, WM_CLOSE, NULL, NULL);
|
||||
}
|
||||
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"Opening 'About' dialog");
|
||||
DialogBoxW(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, (DLGPROC)About);
|
||||
bKPressed = FALSE;
|
||||
diag_log(L"Creating mouse hook failed!");
|
||||
ShowError(IDS_ERR_HOOK);
|
||||
SendMessageW(hWnd, WM_CLOSE, NULL, NULL);
|
||||
}
|
||||
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_DESTROY:
|
||||
{
|
||||
PostQuitMessage(0);
|
||||
}
|
||||
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;
|
||||
HandlingTrayIcon();
|
||||
}
|
||||
if (idMenu == ID_POPUPMENU_AREA)
|
||||
{
|
||||
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 (idMenu == ID_POPUPMENU_ABOUT && !bKPressed)
|
||||
{
|
||||
bKPressed = TRUE;
|
||||
diag_log(L"Opening 'About' dialog");
|
||||
DialogBoxW(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, (DLGPROC)About);
|
||||
bKPressed = FALSE;
|
||||
}
|
||||
if (idMenu == ID_POPUPMENU_EXIT) SendMessageW(hWnd, WM_CLOSE, NULL, NULL);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
return DefWindowProcW(hWnd, message, wParam, lParam);
|
||||
case WM_DESTROY:
|
||||
{
|
||||
PostQuitMessage(0);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
return DefWindowProcW(hWnd, message, wParam, lParam);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -354,7 +360,8 @@ LRESULT CALLBACK KeyboardHookProc(int nCode, WPARAM wParam, LPARAM lParam)
|
||||
if (bApproved)
|
||||
{
|
||||
diag_log(L"Opening 'Manual editing' dialog");
|
||||
DialogBoxW(hInst, MAKEINTRESOURCE(IDD_MANUAL_EDITING), hWnd, (DLGPROC)DlgProc);
|
||||
DialogBoxW(hInst, MAKEINTRESOURCE(IDD_MANUAL_EDITING), hFgWnd, (DLGPROC)DlgProc);
|
||||
SetForegroundWindow(hFgWnd);
|
||||
}
|
||||
else hFgWnd = NULL;
|
||||
bKEYV = FALSE;
|
||||
@@ -369,48 +376,48 @@ BOOL CALLBACK DlgProc(HWND hDlg, UINT dlgmsg, WPARAM wParam, LPARAM lParam)
|
||||
int x, y, w, h;
|
||||
switch (dlgmsg)
|
||||
{
|
||||
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 WM_INITDIALOG:
|
||||
{
|
||||
case IDC_BUTTON_SET:
|
||||
{
|
||||
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;
|
||||
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 IDCANCEL:
|
||||
case IDC_BUTTON_CLOSE:
|
||||
{
|
||||
EndDialog(hDlg, LOWORD(wParam));
|
||||
diag_log(L"Closing 'Manual editing' dialog");
|
||||
break;
|
||||
}
|
||||
}
|
||||
case WM_COMMAND:
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
case IDC_BUTTON_SET:
|
||||
{
|
||||
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;
|
||||
}
|
||||
@@ -472,28 +479,24 @@ VOID ShowError(UINT uID)
|
||||
|
||||
INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
INITCOMMONCONTROLSEX icex;
|
||||
INITCOMMONCONTROLSEX icex = { 0 };
|
||||
icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
|
||||
icex.dwICC = ICC_LINK_CLASS;
|
||||
InitCommonControlsEx(&icex);
|
||||
|
||||
switch (message)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
{
|
||||
SetDlgItemTextW(hDlg, IDC_ABOUTHELP, szAbout);
|
||||
return (INT_PTR)TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_NOTIFY:
|
||||
{
|
||||
LPNMHDR pNMHdr = (LPNMHDR)lParam;
|
||||
switch (pNMHdr->code)
|
||||
case WM_INITDIALOG:
|
||||
{
|
||||
case NM_CLICK:
|
||||
case NM_RETURN:
|
||||
if (pNMHdr->idFrom == IDC_DONATIONLINK)
|
||||
SetDlgItemTextW(hDlg, IDC_ABOUTHELP, szAbout);
|
||||
return (INT_PTR)TRUE;
|
||||
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;
|
||||
LITEM item = pNMLink->item;
|
||||
@@ -503,17 +506,15 @@ INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_COMMAND:
|
||||
if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
|
||||
{
|
||||
EndDialog(hDlg, LOWORD(wParam));
|
||||
diag_log(L"Closing 'About' dialog");
|
||||
return (INT_PTR)TRUE;
|
||||
case WM_COMMAND:
|
||||
if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
|
||||
{
|
||||
EndDialog(hDlg, LOWORD(wParam));
|
||||
diag_log(L"Closing 'About' dialog");
|
||||
return (INT_PTR)TRUE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return (INT_PTR)FALSE;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,42 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
|
||||
|
||||
<description>Centers windows by hotkey (C++)</description>
|
||||
|
||||
<assemblyIdentity
|
||||
version="2.3.3.0"
|
||||
processorArchitecture="x86"
|
||||
name="W0LF.wCenterWindow.C++"
|
||||
type="win32">
|
||||
</assemblyIdentity>
|
||||
|
||||
<dependency>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity
|
||||
type="Win32"
|
||||
name="Microsoft.Windows.Common-Controls"
|
||||
version="6.0.0.0"
|
||||
publicKeyToken="6595b64144ccf1df"
|
||||
language="*"
|
||||
processorArchitecture="*"/>
|
||||
</dependentAssembly>
|
||||
</dependency>
|
||||
|
||||
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
|
||||
<application>
|
||||
<!--ID Windows Vista -->
|
||||
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
|
||||
<!--ID Windows 7 -->
|
||||
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
|
||||
<!--ID Windows 8 -->
|
||||
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
|
||||
<!--ID Windows 8.1 -->
|
||||
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
|
||||
<!--ID Windows 10 -->
|
||||
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
|
||||
</application>
|
||||
</compatibility>
|
||||
|
||||
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||
<security>
|
||||
<requestedPrivileges>
|
||||
@@ -7,15 +44,5 @@
|
||||
</requestedPrivileges>
|
||||
</security>
|
||||
</trustInfo>
|
||||
<dependency>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity
|
||||
type="Win32"
|
||||
name="Microsoft.Windows.Common-Controls"
|
||||
version="6.0.0.0"
|
||||
publicKeyToken="6595b64144ccf1df"
|
||||
language="*"
|
||||
processorArchitecture="*"/>
|
||||
</dependentAssembly>
|
||||
</dependency>
|
||||
|
||||
</assembly>
|
||||
|
||||
Binary file not shown.
@@ -43,13 +43,13 @@
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v141_xp</PlatformToolset>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v141_xp</PlatformToolset>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
@@ -134,6 +134,7 @@
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
@@ -145,12 +146,14 @@
|
||||
<PreprocessorDefinitions>NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
|
||||
Reference in New Issue
Block a user