diff --git a/App.cpp b/App.cpp index 5408402..ff01bf2 100644 --- a/App.cpp +++ b/App.cpp @@ -10,6 +10,7 @@ enum { IDM_SHOWHIDE = 1, IDM_STARTUP = 2, IDM_ABOUT = 3, IDM_EXIT = 4 }; static const UINT WM_TRAY_CALLBACK = WM_APP + 1; static const UINT TRAY_ICON_ID = 1; +static const int HOTKEY_TOGGLE = 1; // global Win+Alt+C -> show/hide UINT g_wmTaskbarCreated = 0; static TrayIcon g_tray; @@ -26,6 +27,9 @@ static LRESULT CALLBACK OwnerWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM return 0; } switch (msg) { + case WM_HOTKEY: + if (wParam == HOTKEY_TOGGLE) ToggleCalculator(); + return 0; case WM_TRAY_CALLBACK: if (LOWORD(lParam) == WM_LBUTTONUP) { ToggleCalculator(); @@ -54,6 +58,7 @@ static LRESULT CALLBACK OwnerWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM } return 0; case WM_DESTROY: + UnregisterHotKey(hWnd, HOTKEY_TOGGLE); g_tray.Remove(); PostQuitMessage(0); return 0; @@ -91,6 +96,12 @@ int WINAPI wWinMain(HINSTANCE hInst, HINSTANCE, LPWSTR, int) g_tray.Add(owner, WM_TRAY_CALLBACK, TRAY_ICON_ID, L"Taskbar Calculator"); + // Global hotkey Win+Alt+C toggles the calculator, exactly like the tray + // click. MOD_NOREPEAT avoids repeated toggles while the keys stay held. + // If the combination is already taken by another app the call just fails + // silently and the tray click still works. + RegisterHotKey(owner, HOTKEY_TOGGLE, MOD_WIN | MOD_ALT | MOD_NOREPEAT, 'C'); + g_calc = new CCalculatorWindow(); g_calc->CreateStandalone(); if (Settings::LoadVisible(true)) // first run (no saved value): visible diff --git a/BuildCounter.txt b/BuildCounter.txt index 7f8f011..f599e28 100644 --- a/BuildCounter.txt +++ b/BuildCounter.txt @@ -1 +1 @@ -7 +10 diff --git a/targetver.h b/targetver.h index 11730d5..2a308bf 100644 --- a/targetver.h +++ b/targetver.h @@ -1,26 +1,18 @@ #pragma once -// The following macros define the minimum required platform. The minimum required platform -// is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run -// your application. The macros work by enabling all features available on platform versions up to and -// including the version specified. +// The following macros define the minimum required platform. This app is a +// Windows 11 system-tray calculator, so we target Windows 10/11 (0x0A00) and +// let all modern APIs (e.g. MOD_NOREPEAT for RegisterHotKey) light up. -// Modify the following defines if you have to target a platform prior to the ones specified below. -// Refer to MSDN for the latest info on corresponding values for different platforms. -#ifndef WINVER // Specifies that the minimum required platform is Windows Vista. -#define WINVER 0x0600 // Change this to the appropriate value to target other versions of Windows. +#ifndef WINVER // Windows 10 / 11 +#define WINVER 0x0A00 #endif -#ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista. -#define _WIN32_WINNT 0x0600 // Change this to the appropriate value to target other versions of Windows. +#ifndef _WIN32_WINNT // Windows 10 / 11 +#define _WIN32_WINNT 0x0A00 #endif -#ifndef _WIN32_WINDOWS // Specifies that the minimum required platform is Windows 98. -#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later. +#ifndef _WIN32_IE // Internet Explorer 11 +#define _WIN32_IE 0x0A00 #endif - -#ifndef _WIN32_IE // Specifies that the minimum required platform is Internet Explorer 7.0. -#define _WIN32_IE 0x0700 // Change this to the appropriate value to target other versions of IE. -#endif - diff --git a/version.h b/version.h index 82b8edc..cc450b7 100644 --- a/version.h +++ b/version.h @@ -3,7 +3,7 @@ // Semantic version — edit these by hand (NOT in the VS resource editor). #define VER_MAJOR 3 #define VER_MINOR 0 -#define VER_BUILD 1 +#define VER_BUILD 2 // Per-build counter. version_build.h is regenerated on every build by the // IncrementBuildCounter MSBuild target (BeforeTargets="ResourceCompile"), so it