Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7491ed2ca7 | |||
| 166cdd0d88 | |||
| d1ab2b86e2 | |||
| 690f621f5b | |||
| 01eb9075b4 | |||
| 5137eed759 | |||
| b8d3db9289 |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -326,7 +326,7 @@ var/
|
|||||||
# PyInstaller
|
# PyInstaller
|
||||||
# Usually these files are written by a python script from a template
|
# Usually these files are written by a python script from a template
|
||||||
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||||
*.manifest
|
#*.manifest
|
||||||
*.spec
|
*.spec
|
||||||
|
|
||||||
# Installer logs
|
# Installer logs
|
||||||
|
|||||||
66
wCenterWindow/Logger.cpp
Normal file
66
wCenterWindow/Logger.cpp
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
// wCenterWindow, v2.3.2
|
||||||
|
// Logger.cpp
|
||||||
|
//
|
||||||
|
#include "framework.h"
|
||||||
|
|
||||||
|
#define TS_LEN 30
|
||||||
|
#define PATH_LEN 1024
|
||||||
|
|
||||||
|
std::wofstream logfile;
|
||||||
|
extern WCHAR szTitle[];
|
||||||
|
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() {
|
||||||
|
SYSTEMTIME lt;
|
||||||
|
GetLocalTime(<);
|
||||||
|
wchar_t 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);
|
||||||
|
return ts;
|
||||||
|
}
|
||||||
|
|
||||||
|
void OpenLogFile() {
|
||||||
|
wchar_t lpszPath[PATH_LEN]{};
|
||||||
|
DWORD dwPathLength = GetModuleFileNameW(NULL, lpszPath, PATH_LEN);
|
||||||
|
DWORD dwError = GetLastError();
|
||||||
|
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) {
|
||||||
|
MessageBoxW(NULL, L"Can't get module filename! Working without logging.", (LPCWSTR)szTitle, MB_OK | MB_ICONWARNING);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
fs::path log_path = lpszPath;
|
||||||
|
log_path.replace_extension(L".log");
|
||||||
|
fs::path bak_path = log_path;
|
||||||
|
bak_path.replace_extension(L".bak");
|
||||||
|
|
||||||
|
if (fs::exists(log_path)) fs::rename(log_path, bak_path);
|
||||||
|
#ifdef _DEBUG
|
||||||
|
log_path = L"d:\\test.log";
|
||||||
|
#endif
|
||||||
|
logfile.open(log_path);
|
||||||
|
if (logfile.is_open()) {
|
||||||
|
diag_log(L"Start logging.");
|
||||||
|
diag_log(L"Logfile:", log_path);
|
||||||
|
diag_log(log_path, L"successfully opened.");
|
||||||
|
} else {
|
||||||
|
MessageBoxW(NULL, L"Can't open logfile! Working without logging.", (LPCWSTR)szTitle, MB_OK | MB_ICONWARNING);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CloseLogFile() {
|
||||||
|
if (logfile) {
|
||||||
|
diag_log(L"End logging.");
|
||||||
|
logfile.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
56
wCenterWindow/Logger.h
Normal file
56
wCenterWindow/Logger.h
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
// wCenterWindow, v2.3.2
|
||||||
|
// Logger.h
|
||||||
|
//
|
||||||
|
#pragma once
|
||||||
|
#include "framework.h"
|
||||||
|
|
||||||
|
extern std::wofstream logfile;
|
||||||
|
std::wstring GetTimeStamp();
|
||||||
|
std::wstring PrintTitle();
|
||||||
|
|
||||||
|
template <typename T1>
|
||||||
|
void diag_log(T1 arg1) {
|
||||||
|
logfile << GetTimeStamp() << arg1 << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T1, typename T2>
|
||||||
|
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) {
|
||||||
|
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;
|
||||||
|
//}
|
||||||
|
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) {
|
||||||
|
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) {
|
||||||
|
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) {
|
||||||
|
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) {
|
||||||
|
logfile << GetTimeStamp() << arg1 << ' ' << arg2 << ' ' << arg3 << ' ' << arg4 << ' ' << arg5 << ' ' << arg6 << ' ' << arg7 << ' ' << arg8 << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
void OpenLogFile();
|
||||||
|
void CloseLogFile();
|
||||||
@@ -7,11 +7,18 @@
|
|||||||
#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
|
||||||
// Windows Header Files
|
// Windows Header Files
|
||||||
#include <windows.h>
|
#include <iostream>
|
||||||
|
#include <fstream>
|
||||||
|
#include <filesystem>
|
||||||
|
#include <string>
|
||||||
#include <strsafe.h>
|
#include <strsafe.h>
|
||||||
|
#include <windows.h>
|
||||||
#include <CommCtrl.h>
|
#include <CommCtrl.h>
|
||||||
|
|
||||||
// C RunTime Header Files
|
// C RunTime Header Files
|
||||||
#include <stdlib.h>
|
//#include <stdlib.h>
|
||||||
#include <malloc.h>
|
//#include <malloc.h>
|
||||||
#include <memory.h>
|
//#include <memory.h>
|
||||||
#include <tchar.h>
|
|
||||||
|
// Project Specific Header Files
|
||||||
|
#include "Logger.h"
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
// wCenterWindow, v2.2
|
// wCenterWindow, v2.3.2
|
||||||
//
|
//
|
||||||
|
// TODO: More verbose logs - partially done.
|
||||||
|
// TODO: More verbose error messages
|
||||||
|
// TODO: Window's title in logs (Impossible?)
|
||||||
|
|
||||||
#include "framework.h"
|
#include "framework.h"
|
||||||
#include "wCenterWindow.h"
|
#include "wCenterWindow.h"
|
||||||
@@ -8,17 +11,19 @@
|
|||||||
#define KEY_C 0x43
|
#define KEY_C 0x43
|
||||||
#define KEY_V 0x56
|
#define KEY_V 0x56
|
||||||
|
|
||||||
|
#define BUF_LEN 4096
|
||||||
#define MAX_LOADSTRING 50
|
#define MAX_LOADSTRING 50
|
||||||
#define WM_WCW 0x8F00
|
#define WM_WCW 0x8F00
|
||||||
|
|
||||||
// Global variables:
|
// Global variables:
|
||||||
HINSTANCE hInst; // Instance
|
HINSTANCE hInst; // Instance
|
||||||
TCHAR szTitle[MAX_LOADSTRING]; // Window's title
|
WCHAR szTitle[MAX_LOADSTRING]; // Window's title
|
||||||
TCHAR szClass[MAX_LOADSTRING]; // Window's class
|
WCHAR szClass[MAX_LOADSTRING]; // Window's class
|
||||||
TCHAR szAbout[MAX_LOADSTRING * 12]; // Description text
|
WCHAR szAbout[MAX_LOADSTRING * 12]; // Description text
|
||||||
TCHAR szWinTitle[256];
|
WCHAR szWinTitle[256];
|
||||||
TCHAR szWinClass[256];
|
WCHAR szWinClass[256];
|
||||||
TCHAR szWinCore[] = TEXT("Windows.UI.Core.CoreWindow");
|
WCHAR szWinCore[] = TEXT("Windows.UI.Core.CoreWindow");
|
||||||
|
HANDLE hHeap = NULL;
|
||||||
HHOOK hMouseHook = NULL, hKbdHook = NULL; // Hook's handles
|
HHOOK hMouseHook = NULL, hKbdHook = NULL; // Hook's handles
|
||||||
HICON hIcon = NULL;
|
HICON hIcon = NULL;
|
||||||
HMENU hMenu = NULL, hPopup = NULL;
|
HMENU hMenu = NULL, hPopup = NULL;
|
||||||
@@ -31,6 +36,8 @@ NOTIFYICONDATA nid = { 0 };
|
|||||||
LPKBDLLHOOKSTRUCT pkhs;
|
LPKBDLLHOOKSTRUCT pkhs;
|
||||||
MENUITEMINFO mii;
|
MENUITEMINFO mii;
|
||||||
|
|
||||||
|
LPVOID szBuffer;
|
||||||
|
|
||||||
// Forward declarations of functions included in this code module:
|
// Forward declarations of functions included in this code module:
|
||||||
VOID HandlingTrayIcon();
|
VOID HandlingTrayIcon();
|
||||||
VOID ShowError(UINT);
|
VOID ShowError(UINT);
|
||||||
@@ -49,24 +56,28 @@ ATOM MyRegisterClass(HINSTANCE hInstance)
|
|||||||
wcex.cbSize = sizeof(WNDCLASSEX);
|
wcex.cbSize = sizeof(WNDCLASSEX);
|
||||||
wcex.lpfnWndProc = WndProc;
|
wcex.lpfnWndProc = WndProc;
|
||||||
wcex.hInstance = hInstance;
|
wcex.hInstance = hInstance;
|
||||||
wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_TRAYICON));
|
wcex.hIcon = LoadIconW(hInstance, MAKEINTRESOURCE(IDI_TRAYICON));
|
||||||
wcex.hCursor = LoadCursor(nullptr, IDC_ARROW);
|
wcex.hCursor = LoadCursorW(nullptr, IDC_ARROW);
|
||||||
wcex.lpszClassName = szClass;
|
wcex.lpszClassName = szClass;
|
||||||
wcex.hIconSm = wcex.hIcon;
|
wcex.hIconSm = wcex.hIcon;
|
||||||
hIcon = wcex.hIcon;
|
hIcon = wcex.hIcon;
|
||||||
return RegisterClassEx(&wcex);
|
return RegisterClassExW(&wcex);
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
RECT fgwrc;
|
RECT fgwrc;
|
||||||
GetWindowRect(hwnd, &fgwrc);
|
GetWindowRect(hwnd, &fgwrc);
|
||||||
LONG nWidth = fgwrc.right - fgwrc.left;
|
LONG nWidth = fgwrc.right - fgwrc.left;
|
||||||
LONG nHeight = fgwrc.bottom - fgwrc.top;
|
LONG nHeight = fgwrc.bottom - fgwrc.top;
|
||||||
|
|
||||||
|
diag_log(L"Moving window from x =", fgwrc.left, L"y =", fgwrc.top);
|
||||||
|
|
||||||
MONITORINFO mi;
|
MONITORINFO mi;
|
||||||
mi.cbSize = sizeof(MONITORINFO);
|
mi.cbSize = sizeof(MONITORINFO);
|
||||||
GetMonitorInfo(MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST), &mi);
|
GetMonitorInfoW(MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST), &mi);
|
||||||
RECT area;
|
RECT area;
|
||||||
if (bWorkArea)
|
if (bWorkArea)
|
||||||
{
|
{
|
||||||
@@ -92,31 +103,37 @@ VOID MoveWindowToMonitorCenter(HWND hwnd, BOOL bWorkArea, BOOL bResize)
|
|||||||
int x = (aw - nWidth) / 2;
|
int x = (aw - nWidth) / 2;
|
||||||
int y = (ah - nHeight) / 2;
|
int y = (ah - nHeight) / 2;
|
||||||
|
|
||||||
SendMessage(hwnd, WM_ENTERSIZEMOVE, NULL, NULL);
|
SendMessageW(hwnd, WM_ENTERSIZEMOVE, NULL, NULL);
|
||||||
MoveWindow(hwnd, x, y, nWidth, nHeight, TRUE);
|
MoveWindow(hwnd, x, y, nWidth, nHeight, TRUE);
|
||||||
SendMessage(hwnd, WM_EXITSIZEMOVE, NULL, NULL);
|
SendMessageW(hwnd, WM_EXITSIZEMOVE, NULL, NULL);
|
||||||
|
|
||||||
|
diag_log(L"Moving window to x =", x, L"y =", y);
|
||||||
|
diag_log(L"Quiting MoveWindowToMonitorCenter()");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
|
int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow)
|
||||||
{
|
{
|
||||||
UNREFERENCED_PARAMETER(hPrevInstance);
|
UNREFERENCED_PARAMETER(hPrevInstance);
|
||||||
UNREFERENCED_PARAMETER(lpCmdLine);
|
UNREFERENCED_PARAMETER(lpCmdLine);
|
||||||
|
|
||||||
|
OpenLogFile();
|
||||||
|
diag_log(L"Entering WinMain()");
|
||||||
|
|
||||||
hInst = hInstance;
|
hInst = hInstance;
|
||||||
|
|
||||||
LoadString(hInstance, IDS_APP_TITLE, szTitle, _countof(szTitle));
|
LoadStringW(hInstance, IDS_APP_TITLE, szTitle, _countof(szTitle));
|
||||||
LoadString(hInstance, IDS_CLASSNAME, szClass, _countof(szClass));
|
LoadStringW(hInstance, IDS_CLASSNAME, szClass, _countof(szClass));
|
||||||
|
|
||||||
if (FindWindow(szClass, NULL))
|
if (FindWindowW(szClass, NULL))
|
||||||
{
|
{
|
||||||
ShowError(IDS_RUNNING);
|
ShowError(IDS_RUNNING);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
MyRegisterClass(hInstance);
|
MyRegisterClass(hInstance);
|
||||||
hWnd = CreateWindowEx(0, szClass, szTitle, 0, 0, 0, 0, 0, NULL, NULL, hInstance, NULL);
|
hWnd = CreateWindowExW(0, szClass, szTitle, 0, 0, 0, 0, 0, NULL, NULL, hInstance, NULL);
|
||||||
if (!hWnd)
|
if (!hWnd)
|
||||||
{
|
{
|
||||||
ShowError(IDS_ERR_WND);
|
ShowError(IDS_ERR_WND);
|
||||||
@@ -125,18 +142,28 @@ int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCm
|
|||||||
|
|
||||||
int nArgs = 0;
|
int nArgs = 0;
|
||||||
LPWSTR* szArglist = CommandLineToArgvW(GetCommandLineW(), &nArgs);
|
LPWSTR* szArglist = CommandLineToArgvW(GetCommandLineW(), &nArgs);
|
||||||
(nArgs >= 2 && 0 == lstrcmpiW(szArglist[1], TEXT("/hide"))) ? bShowIcon = FALSE : bShowIcon = TRUE;
|
|
||||||
|
diag_log(L"Arguments:", nArgs);
|
||||||
|
for (int i = 0; i < nArgs; i++)
|
||||||
|
{
|
||||||
|
diag_log(L"Argument", i, L":", szArglist[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
(nArgs >= 2 && 0 == lstrcmpiW(szArglist[1], L"/hide")) ? bShowIcon = FALSE : bShowIcon = TRUE;
|
||||||
LocalFree(szArglist);
|
LocalFree(szArglist);
|
||||||
HandlingTrayIcon();
|
HandlingTrayIcon();
|
||||||
|
|
||||||
hTaskBar = FindWindow(TEXT("Shell_TrayWnd"), NULL);
|
hHeap = GetProcessHeap();
|
||||||
hProgman = FindWindow(TEXT("Progman"), NULL);
|
szBuffer = HeapAlloc(hHeap, HEAP_ZERO_MEMORY, BUF_LEN);
|
||||||
|
|
||||||
|
hTaskBar = FindWindowW(L"Shell_TrayWnd", NULL);
|
||||||
|
hProgman = FindWindowW(L"Progman", NULL);
|
||||||
hDesktop = GetDesktopWindow();
|
hDesktop = GetDesktopWindow();
|
||||||
|
|
||||||
MSG msg;
|
MSG msg;
|
||||||
BOOL bRet;
|
BOOL bRet;
|
||||||
|
|
||||||
while ((bRet = GetMessage(&msg, NULL, 0, 0)) != 0)
|
while ((bRet = GetMessageW(&msg, NULL, 0, 0)) != 0)
|
||||||
{
|
{
|
||||||
if (bRet == -1)
|
if (bRet == -1)
|
||||||
{
|
{
|
||||||
@@ -146,14 +173,18 @@ int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCm
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
TranslateMessage(&msg);
|
TranslateMessage(&msg);
|
||||||
DispatchMessage(&msg);
|
DispatchMessageW(&msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hMouseHook) UnhookWindowsHookEx(hMouseHook);
|
if (hMouseHook) UnhookWindowsHookEx(hMouseHook);
|
||||||
if (hKbdHook) UnhookWindowsHookEx(hKbdHook);
|
if (hKbdHook) UnhookWindowsHookEx(hKbdHook);
|
||||||
if (hMenu) DestroyMenu(hMenu);
|
if (hMenu) DestroyMenu(hMenu);
|
||||||
Shell_NotifyIcon(NIM_DELETE, &nid);
|
Shell_NotifyIconW(NIM_DELETE, &nid);
|
||||||
|
|
||||||
|
diag_log(L"Quiting WinMain(), msg.wParam =", (int)msg.wParam);
|
||||||
|
CloseLogFile();
|
||||||
|
HeapFree(hHeap, NULL, szBuffer);
|
||||||
|
|
||||||
return (int)msg.wParam;
|
return (int)msg.wParam;
|
||||||
}
|
}
|
||||||
@@ -162,93 +193,103 @@ 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)
|
||||||
{
|
{
|
||||||
hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_MENU));
|
diag_log(L"Loading context menu failed!");
|
||||||
if (!hMenu)
|
ShowError(IDS_ERR_MENU);
|
||||||
{
|
SendMessageW(hWnd, WM_CLOSE, NULL, NULL);
|
||||||
ShowError(IDS_ERR_MENU);
|
|
||||||
SendMessage(hWnd, WM_CLOSE, NULL, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
hPopup = GetSubMenu(hMenu, 0);
|
|
||||||
if (!hPopup)
|
|
||||||
{
|
|
||||||
ShowError(IDS_ERR_POPUP);
|
|
||||||
SendMessage(hWnd, WM_CLOSE, NULL, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
mii.cbSize = sizeof(MENUITEMINFO);
|
|
||||||
mii.fMask = MIIM_STATE;
|
|
||||||
bWorkArea ? mii.fState = MFS_CHECKED : mii.fState = MFS_UNCHECKED;
|
|
||||||
SetMenuItemInfo(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;
|
|
||||||
StringCchCopy(nid.szTip, _countof(nid.szTip), szTitle);
|
|
||||||
|
|
||||||
hMouseHook = SetWindowsHookEx(WH_MOUSE_LL, MouseHookProc, hInst, NULL);
|
|
||||||
if (!hMouseHook)
|
|
||||||
{
|
|
||||||
ShowError(IDS_ERR_HOOK);
|
|
||||||
SendMessage(hWnd, WM_CLOSE, NULL, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
hKbdHook = SetWindowsHookEx(WH_KEYBOARD_LL, KeyboardHookProc, hInst, NULL);
|
|
||||||
if (!hKbdHook)
|
|
||||||
{
|
|
||||||
ShowError(IDS_ERR_HOOK);
|
|
||||||
SendMessage(hWnd, WM_CLOSE, NULL, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
LoadString(hInst, IDS_ABOUT, szAbout, _countof(szAbout));
|
|
||||||
}
|
}
|
||||||
break;
|
diag_log(L"Context menu successfully loaded");
|
||||||
|
|
||||||
case WM_WCW:
|
hPopup = GetSubMenu(hMenu, 0);
|
||||||
|
if (!hPopup)
|
||||||
{
|
{
|
||||||
if ((lParam == WM_RBUTTONDOWN || lParam == WM_LBUTTONDOWN) && wParam == IDI_TRAYICON)
|
diag_log(L"Creating popup menu failed!");
|
||||||
{
|
ShowError(IDS_ERR_POPUP);
|
||||||
SetForegroundWindow(hWnd);
|
SendMessageW(hWnd, WM_CLOSE, NULL, NULL);
|
||||||
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;
|
|
||||||
SetMenuItemInfo(hPopup, ID_POPUPMENU_AREA, FALSE, &mii);
|
|
||||||
}
|
|
||||||
if (idMenu == ID_POPUPMENU_ABOUT && !bKPressed)
|
|
||||||
{
|
|
||||||
bKPressed = TRUE;
|
|
||||||
DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, (DLGPROC)About);
|
|
||||||
bKPressed = FALSE;
|
|
||||||
}
|
|
||||||
if (idMenu == ID_POPUPMENU_EXIT) SendMessage(hWnd, WM_CLOSE, NULL, NULL);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
diag_log(L"Popup menu successfully created");
|
||||||
|
|
||||||
case WM_DESTROY:
|
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)
|
||||||
{
|
{
|
||||||
PostQuitMessage(0);
|
diag_log(L"Creating mouse hook failed!");
|
||||||
|
ShowError(IDS_ERR_HOOK);
|
||||||
|
SendMessageW(hWnd, WM_CLOSE, NULL, NULL);
|
||||||
}
|
}
|
||||||
break;
|
diag_log(L"Mouse hook was successfully set");
|
||||||
|
|
||||||
default:
|
hKbdHook = SetWindowsHookExW(WH_KEYBOARD_LL, KeyboardHookProc, hInst, NULL);
|
||||||
return DefWindowProc(hWnd, message, wParam, lParam);
|
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;
|
||||||
|
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;
|
||||||
|
|
||||||
|
case WM_DESTROY:
|
||||||
|
{
|
||||||
|
PostQuitMessage(0);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return DefWindowProcW(hWnd, message, wParam, lParam);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -258,6 +299,7 @@ LRESULT CALLBACK MouseHookProc(int nCode, WPARAM wParam, LPARAM lParam)
|
|||||||
if (wParam == WM_MBUTTONUP) bMPressed = FALSE;
|
if (wParam == WM_MBUTTONUP) bMPressed = FALSE;
|
||||||
if (wParam == WM_MBUTTONDOWN && bLCTRL && bLWIN && !bMPressed)
|
if (wParam == WM_MBUTTONDOWN && bLCTRL && bLWIN && !bMPressed)
|
||||||
{
|
{
|
||||||
|
diag_log(L"Pressed LCTRL + LWIN + MMB");
|
||||||
bMPressed = TRUE;
|
bMPressed = TRUE;
|
||||||
hFgWnd = GetForegroundWindow();
|
hFgWnd = GetForegroundWindow();
|
||||||
BOOL bApproved = CheckWindow(hFgWnd);
|
BOOL bApproved = CheckWindow(hFgWnd);
|
||||||
@@ -285,6 +327,7 @@ LRESULT CALLBACK KeyboardHookProc(int nCode, WPARAM wParam, LPARAM lParam)
|
|||||||
|
|
||||||
if (bLCTRL && bLWIN && pkhs->vkCode == KEY_I && !bKPressed) // 'I' key
|
if (bLCTRL && bLWIN && pkhs->vkCode == KEY_I && !bKPressed) // 'I' key
|
||||||
{
|
{
|
||||||
|
diag_log(L"Pressed LCTRL + LWIN + I");
|
||||||
bKPressed = TRUE;
|
bKPressed = TRUE;
|
||||||
bShowIcon = !bShowIcon;
|
bShowIcon = !bShowIcon;
|
||||||
HandlingTrayIcon();
|
HandlingTrayIcon();
|
||||||
@@ -293,6 +336,7 @@ LRESULT CALLBACK KeyboardHookProc(int nCode, WPARAM wParam, LPARAM lParam)
|
|||||||
|
|
||||||
if (bLCTRL && bLWIN && pkhs->vkCode == KEY_C && !bKPressed && !bKEYV) // 'C' key
|
if (bLCTRL && bLWIN && pkhs->vkCode == KEY_C && !bKPressed && !bKEYV) // 'C' key
|
||||||
{
|
{
|
||||||
|
diag_log(L"Pressed LCTRL + LWIN + C");
|
||||||
bKPressed = TRUE;
|
bKPressed = TRUE;
|
||||||
hFgWnd = GetForegroundWindow();
|
hFgWnd = GetForegroundWindow();
|
||||||
BOOL bApproved = CheckWindow(hFgWnd);
|
BOOL bApproved = CheckWindow(hFgWnd);
|
||||||
@@ -303,10 +347,15 @@ LRESULT CALLBACK KeyboardHookProc(int nCode, WPARAM wParam, LPARAM lParam)
|
|||||||
|
|
||||||
if (bLCTRL && bLWIN && pkhs->vkCode == KEY_V && !bKPressed && !bKEYV) // 'V' key
|
if (bLCTRL && bLWIN && pkhs->vkCode == KEY_V && !bKPressed && !bKEYV) // 'V' key
|
||||||
{
|
{
|
||||||
|
diag_log(L"Pressed LCTRL + LWIN + V");
|
||||||
bKPressed = TRUE; bKEYV = TRUE;
|
bKPressed = TRUE; bKEYV = TRUE;
|
||||||
hFgWnd = GetForegroundWindow();
|
hFgWnd = GetForegroundWindow();
|
||||||
BOOL bApproved = CheckWindow(hFgWnd);
|
BOOL bApproved = CheckWindow(hFgWnd);
|
||||||
if (bApproved) DialogBox(hInst, MAKEINTRESOURCE(IDD_MANUAL_EDITING), hWnd, (DLGPROC)DlgProc);
|
if (bApproved)
|
||||||
|
{
|
||||||
|
diag_log(L"Opening 'Manual editing' dialog");
|
||||||
|
DialogBoxW(hInst, MAKEINTRESOURCE(IDD_MANUAL_EDITING), hWnd, (DLGPROC)DlgProc);
|
||||||
|
}
|
||||||
else hFgWnd = NULL;
|
else hFgWnd = NULL;
|
||||||
bKEYV = FALSE;
|
bKEYV = FALSE;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@@ -320,89 +369,105 @@ 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))
|
||||||
{
|
{
|
||||||
SetWindowText(hDlg, szTitle);
|
case IDC_BUTTON_SET:
|
||||||
GetWindowText(hFgWnd, szWinTitle, _countof(szWinTitle));
|
{
|
||||||
GetClassName(hFgWnd, szWinClass, _countof(szWinClass));
|
x = GetDlgItemInt(hDlg, IDC_EDIT_X, NULL, TRUE);
|
||||||
GetWindowRect(hFgWnd, &rcFW);
|
y = GetDlgItemInt(hDlg, IDC_EDIT_Y, NULL, TRUE);
|
||||||
x = rcFW.left;
|
w = GetDlgItemInt(hDlg, IDC_EDIT_WIDTH, NULL, FALSE);
|
||||||
y = rcFW.top;
|
h = GetDlgItemInt(hDlg, IDC_EDIT_HEIGHT, NULL, FALSE);
|
||||||
w = rcFW.right - rcFW.left;
|
SendMessageW(hFgWnd, WM_ENTERSIZEMOVE, NULL, NULL);
|
||||||
h = rcFW.bottom - rcFW.top;
|
MoveWindow(hFgWnd, x, y, w, h, TRUE);
|
||||||
SetDlgItemInt(hDlg, IDC_EDIT_X, x, TRUE);
|
SendMessageW(hFgWnd, WM_EXITSIZEMOVE, NULL, NULL);
|
||||||
SetDlgItemInt(hDlg, IDC_EDIT_Y, y, TRUE);
|
return TRUE;
|
||||||
SetDlgItemInt(hDlg, IDC_EDIT_WIDTH, w, FALSE);
|
|
||||||
SetDlgItemInt(hDlg, IDC_EDIT_HEIGHT, h, FALSE);
|
|
||||||
SetDlgItemText(hDlg, IDC_EDIT_TITLE, szWinTitle);
|
|
||||||
SetDlgItemText(hDlg, IDC_EDIT_CLASS, szWinClass);
|
|
||||||
UpdateWindow(hDlg);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case WM_COMMAND:
|
case IDCANCEL:
|
||||||
switch (LOWORD(wParam))
|
case IDC_BUTTON_CLOSE:
|
||||||
{
|
{
|
||||||
case IDC_BUTTON_SET:
|
EndDialog(hDlg, LOWORD(wParam));
|
||||||
{
|
diag_log(L"Closing 'Manual editing' dialog");
|
||||||
x = GetDlgItemInt(hDlg, IDC_EDIT_X, NULL, TRUE);
|
break;
|
||||||
y = GetDlgItemInt(hDlg, IDC_EDIT_Y, NULL, TRUE);
|
}
|
||||||
w = GetDlgItemInt(hDlg, IDC_EDIT_WIDTH, NULL, FALSE);
|
}
|
||||||
h = GetDlgItemInt(hDlg, IDC_EDIT_HEIGHT, NULL, FALSE);
|
|
||||||
SendMessage(hFgWnd, WM_ENTERSIZEMOVE, NULL, NULL);
|
|
||||||
MoveWindow(hFgWnd, x, y, w, h, TRUE);
|
|
||||||
SendMessage(hFgWnd, WM_EXITSIZEMOVE, NULL, NULL);
|
|
||||||
return TRUE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case IDCANCEL:
|
|
||||||
case IDC_BUTTON_CLOSE:
|
|
||||||
{
|
|
||||||
EndDialog(hDlg, LOWORD(wParam));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL CheckWindow(HWND hFW)
|
BOOL CheckWindow(HWND hFW)
|
||||||
{
|
{
|
||||||
GetClassName(hFW, szWinClass, _countof(szWinClass));
|
diag_log(L"Entering CheckWindow(), hwnd=", hFW);
|
||||||
|
GetClassNameW(hFW, szWinClass, _countof(szWinClass));
|
||||||
if (hFW)
|
if (hFW)
|
||||||
{
|
{
|
||||||
if (_tcscmp(szWinClass, szWinCore) != 0)
|
if (wcscmp(szWinClass, szWinCore) != 0)
|
||||||
{
|
{
|
||||||
if (hFW != hDesktop && hFW != hTaskBar && hFW != hProgman)
|
if (hFW != hDesktop && hFW != hTaskBar && hFW != hProgman)
|
||||||
{
|
{
|
||||||
if (!IsIconic(hFW) && !IsZoomed(hFW)) return TRUE;
|
if (!IsIconic(hFW) && !IsZoomed(hFW))
|
||||||
|
{
|
||||||
|
GetWindowTextW(hFW, (LPWSTR)szBuffer, BUF_LEN - sizeof(WCHAR));
|
||||||
|
diag_log(L"Window with hwnd=", hFW, L"is approved");
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
else ShowError(IDS_ERR_MAXMIN);
|
else ShowError(IDS_ERR_MAXMIN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
diag_log(L"Window with hwnd=", hFW, L"is not approved!");
|
||||||
|
diag_log(L"Quiting CheckWindow()");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID HandlingTrayIcon()
|
VOID HandlingTrayIcon()
|
||||||
{
|
{
|
||||||
|
diag_log(L"Entering HandlingTrayIcon(), bShowIcon =", bShowIcon);
|
||||||
if (bShowIcon)
|
if (bShowIcon)
|
||||||
{
|
{
|
||||||
if (!Shell_NotifyIcon(NIM_ADD, &nid))
|
BOOL bResult1 = Shell_NotifyIconW(NIM_ADD, &nid);
|
||||||
|
diag_log(L"Shell_NotifyIconW(NIM_ADD):", bResult1);
|
||||||
|
BOOL bResult2 = Shell_NotifyIconW(NIM_SETVERSION, &nid);
|
||||||
|
diag_log(L"Shell_NotifyIconW(NIM_SETVERSION):", bResult2);
|
||||||
|
if (!bResult1 || !bResult2)
|
||||||
{
|
{
|
||||||
|
diag_log(L"Error creating trayicon.");
|
||||||
ShowError(IDS_ERR_ICON);
|
ShowError(IDS_ERR_ICON);
|
||||||
bShowIcon = FALSE;
|
bShowIcon = FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Shell_NotifyIcon(NIM_DELETE, &nid);
|
Shell_NotifyIconW(NIM_DELETE, &nid);
|
||||||
}
|
}
|
||||||
|
diag_log(L"Quiting HandlingTrayIcon()");
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID ShowError(UINT uID)
|
VOID ShowError(UINT uID)
|
||||||
{
|
{
|
||||||
TCHAR szErrorText[MAX_LOADSTRING]; // Error's text
|
WCHAR szErrorText[MAX_LOADSTRING]; // Error's text
|
||||||
LoadString(hInst, uID, szErrorText, _countof(szErrorText));
|
LoadStringW(hInst, uID, szErrorText, _countof(szErrorText));
|
||||||
MessageBox(hWnd, szErrorText, szTitle, MB_OK | MB_ICONERROR | MB_TOPMOST);
|
MessageBoxW(hWnd, 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)
|
||||||
@@ -414,39 +479,41 @@ 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)
|
||||||
{
|
{
|
||||||
SetDlgItemText(hDlg, IDC_ABOUTHELP, szAbout);
|
case NM_CLICK:
|
||||||
|
case NM_RETURN:
|
||||||
|
if (pNMHdr->idFrom == IDC_DONATIONLINK)
|
||||||
|
{
|
||||||
|
PNMLINK pNMLink = (PNMLINK)pNMHdr;
|
||||||
|
LITEM item = pNMLink->item;
|
||||||
|
ShellExecuteW(NULL, L"open", item.szUrl, NULL, NULL, SW_SHOW);
|
||||||
|
diag_log(L"Pressed donation link");
|
||||||
|
return (INT_PTR)TRUE;
|
||||||
|
}
|
||||||
|
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;
|
return (INT_PTR)TRUE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case WM_NOTIFY:
|
|
||||||
{
|
|
||||||
LPNMHDR pNMHdr = (LPNMHDR)lParam;
|
|
||||||
switch (pNMHdr->code)
|
|
||||||
{
|
|
||||||
case NM_CLICK:
|
|
||||||
case NM_RETURN:
|
|
||||||
if (pNMHdr->idFrom == IDC_DONATIONLINK)
|
|
||||||
{
|
|
||||||
PNMLINK pNMLink = (PNMLINK)pNMHdr;
|
|
||||||
LITEM item = pNMLink->item;
|
|
||||||
ShellExecute(NULL, L"open", item.szUrl, NULL, NULL, SW_SHOW);
|
|
||||||
return (INT_PTR)TRUE;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case WM_COMMAND:
|
|
||||||
if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
|
|
||||||
{
|
|
||||||
EndDialog(hDlg, LOWORD(wParam));
|
|
||||||
return (INT_PTR)TRUE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return (INT_PTR)FALSE;
|
return (INT_PTR)FALSE;
|
||||||
}
|
}
|
||||||
|
|||||||
21
wCenterWindow/wCenterWindow.manifest
Normal file
21
wCenterWindow/wCenterWindow.manifest
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
<?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">
|
||||||
|
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||||
|
<security>
|
||||||
|
<requestedPrivileges>
|
||||||
|
<requestedExecutionLevel level="asInvoker" uiAccess="false"></requestedExecutionLevel>
|
||||||
|
</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.
@@ -24,31 +24,32 @@
|
|||||||
<ProjectGuid>{f1a1603a-f5d0-47b8-8e4b-cf17747bcfba}</ProjectGuid>
|
<ProjectGuid>{f1a1603a-f5d0-47b8-8e4b-cf17747bcfba}</ProjectGuid>
|
||||||
<RootNamespace>wCenterWindow</RootNamespace>
|
<RootNamespace>wCenterWindow</RootNamespace>
|
||||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||||
|
<XPDeprecationWarning>false</XPDeprecationWarning>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
<PlatformToolset>v142</PlatformToolset>
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
<PlatformToolset>v142</PlatformToolset>
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
<PlatformToolset>v142</PlatformToolset>
|
<PlatformToolset>v141_xp</PlatformToolset>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
<PlatformToolset>v142</PlatformToolset>
|
<PlatformToolset>v141_xp</PlatformToolset>
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
@@ -88,7 +89,8 @@
|
|||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<ConformanceMode>true</ConformanceMode>
|
<ConformanceMode>false</ConformanceMode>
|
||||||
|
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
@@ -108,6 +110,7 @@
|
|||||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<ConformanceMode>true</ConformanceMode>
|
<ConformanceMode>true</ConformanceMode>
|
||||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
|
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
@@ -126,6 +129,7 @@
|
|||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<PreprocessorDefinitions>_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<ConformanceMode>true</ConformanceMode>
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
@@ -140,6 +144,7 @@
|
|||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<PreprocessorDefinitions>NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<ConformanceMode>true</ConformanceMode>
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
@@ -150,11 +155,13 @@
|
|||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="framework.h" />
|
<ClInclude Include="framework.h" />
|
||||||
|
<ClInclude Include="Logger.h" />
|
||||||
<ClInclude Include="Resource.h" />
|
<ClInclude Include="Resource.h" />
|
||||||
<ClInclude Include="targetver.h" />
|
<ClInclude Include="targetver.h" />
|
||||||
<ClInclude Include="wCenterWindow.h" />
|
<ClInclude Include="wCenterWindow.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ClCompile Include="Logger.cpp" />
|
||||||
<ClCompile Include="wCenterWindow.cpp" />
|
<ClCompile Include="wCenterWindow.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -27,11 +27,17 @@
|
|||||||
<ClInclude Include="wCenterWindow.h">
|
<ClInclude Include="wCenterWindow.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="Logger.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="wCenterWindow.cpp">
|
<ClCompile Include="wCenterWindow.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="Logger.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ResourceCompile Include="wCenterWindow.rc">
|
<ResourceCompile Include="wCenterWindow.rc">
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<PropertyGroup />
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<LocalDebuggerCommandArguments>/test1 /test2</LocalDebuggerCommandArguments>
|
||||||
|
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
||||||
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
||||||
Reference in New Issue
Block a user