upt
This commit is contained in:
parent
248244b108
commit
b4aa8ff165
@ -118,6 +118,7 @@
|
|||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<ConformanceMode>true</ConformanceMode>
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
<LanguageStandard>stdcpp20</LanguageStandard>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
|
|
||||||
const MARGINS margins = { -1 ,-1, -1, -1 };
|
const MARGINS margins = { -1 ,-1, -1, -1 };
|
||||||
const wchar_t g_szClassName[] = L"overlay";
|
const wchar_t g_szClassName[] = L"overlay";
|
||||||
|
|
||||||
bool isVisible = true;
|
bool isVisible = true;
|
||||||
|
|
||||||
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
@ -13,11 +12,16 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|||||||
switch (msg)
|
switch (msg)
|
||||||
{
|
{
|
||||||
case WM_HOTKEY:
|
case WM_HOTKEY:
|
||||||
if (wParam == 1) // При нажатии на горячую клавишу
|
if (wParam == 1) // При нажатии на горячую клавишу ALT + Z
|
||||||
{
|
{
|
||||||
isVisible = !isVisible; // Èíâåðòèðóåì çíà÷åíèå ïåðåìåííîé isVisible
|
isVisible = !isVisible; // Èíâåðòèðóåì çíà÷åíèå ïåðåìåííîé isVisible
|
||||||
ShowWindow(hwnd, isVisible ? SW_SHOW : SW_HIDE); // Ïîêàçûâàåì/ñêðûâàåì îêíî â çàâèñèìîñòè îò çíà÷åíèÿ isVisible
|
ShowWindow(hwnd, isVisible ? SW_SHOW : SW_HIDE); // Ïîêàçûâàåì/ñêðûâàåì îêíî â çàâèñèìîñòè îò çíà÷åíèÿ isVisible
|
||||||
}
|
}
|
||||||
|
else if (wParam == 2) // При нажатии на горячую клавишу ALT + X
|
||||||
|
{
|
||||||
|
// Закрытие окна
|
||||||
|
DestroyWindow(hwnd);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case WM_PAINT:
|
case WM_PAINT:
|
||||||
{
|
{
|
||||||
@ -40,8 +44,6 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
|
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
|
||||||
{
|
{
|
||||||
WNDCLASSEX wc;
|
WNDCLASSEX wc;
|
||||||
@ -78,6 +80,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
|
|||||||
|
|
||||||
// Ðåãèñòðàöèÿ ãîðÿ÷åé êëàâèøè
|
// Ðåãèñòðàöèÿ ãîðÿ÷åé êëàâèøè
|
||||||
RegisterHotKey(hwnd, 1, MOD_ALT, 0x5A); // Çäåñü 0x5A ñîîòâåòñòâóåò êëàâèøå Z
|
RegisterHotKey(hwnd, 1, MOD_ALT, 0x5A); // Çäåñü 0x5A ñîîòâåòñòâóåò êëàâèøå Z
|
||||||
|
RegisterHotKey(hwnd, 2, MOD_ALT, 0x58); // Здесь 0x58 соответствует клавише X
|
||||||
|
|
||||||
// Öèêë îáðàáîòêè ñîîáùåíèé
|
// Öèêë îáðàáîòêè ñîîáùåíèé
|
||||||
while (GetMessage(&Msg, NULL, 0, 0) > 0)
|
while (GetMessage(&Msg, NULL, 0, 0) > 0)
|
||||||
@ -88,6 +91,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
|
|||||||
|
|
||||||
// Óäàëåíèå ãîðÿ÷åé êëàâèøè
|
// Óäàëåíèå ãîðÿ÷åé êëàâèøè
|
||||||
UnregisterHotKey(hwnd, 1);
|
UnregisterHotKey(hwnd, 1);
|
||||||
|
UnregisterHotKey(hwnd, 2);
|
||||||
|
|
||||||
exit(0);
|
exit(0);
|
||||||
return Msg.wParam;
|
return Msg.wParam;
|
||||||
|
Loading…
Reference in New Issue
Block a user