From dd934a11d09fb6e4992f28774543d74db59d46c8 Mon Sep 17 00:00:00 2001 From: vosrhd9 Date: Fri, 10 Mar 2023 02:03:13 +0300 Subject: [PATCH] update --- Overlay.sln | 22 +++++--- Overlay/Overlay.vcxproj | 78 ++++++++++++++++++++++----- Overlay/Overlay.vcxproj.filters | 18 ++++++- Overlay/Source.cpp | 94 +++++++++++++++++++++++++++++++++ 4 files changed, 190 insertions(+), 22 deletions(-) create mode 100644 Overlay/Source.cpp diff --git a/Overlay.sln b/Overlay.sln index 1c94595..cdfb765 100644 --- a/Overlay.sln +++ b/Overlay.sln @@ -1,25 +1,31 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.29519.87 +# Visual Studio Version 17 +VisualStudioVersion = 17.4.33403.182 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Overlay", "Overlay\Overlay.vcxproj", "{68C049A1-7EA4-45D2-942C-7710AF16B1FA}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "overlay", "overlay\overlay.vcxproj", "{8C1934F5-BFA2-4CF2-8A40-A6C0CA1A1661}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 Release|x64 = Release|x64 + Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {68C049A1-7EA4-45D2-942C-7710AF16B1FA}.Debug|x64.ActiveCfg = Debug|x64 - {68C049A1-7EA4-45D2-942C-7710AF16B1FA}.Debug|x64.Build.0 = Debug|x64 - {68C049A1-7EA4-45D2-942C-7710AF16B1FA}.Release|x64.ActiveCfg = Release|x64 - {68C049A1-7EA4-45D2-942C-7710AF16B1FA}.Release|x64.Build.0 = Release|x64 + {8C1934F5-BFA2-4CF2-8A40-A6C0CA1A1661}.Debug|x64.ActiveCfg = Debug|x64 + {8C1934F5-BFA2-4CF2-8A40-A6C0CA1A1661}.Debug|x64.Build.0 = Debug|x64 + {8C1934F5-BFA2-4CF2-8A40-A6C0CA1A1661}.Debug|x86.ActiveCfg = Debug|Win32 + {8C1934F5-BFA2-4CF2-8A40-A6C0CA1A1661}.Debug|x86.Build.0 = Debug|Win32 + {8C1934F5-BFA2-4CF2-8A40-A6C0CA1A1661}.Release|x64.ActiveCfg = Release|x64 + {8C1934F5-BFA2-4CF2-8A40-A6C0CA1A1661}.Release|x64.Build.0 = Release|x64 + {8C1934F5-BFA2-4CF2-8A40-A6C0CA1A1661}.Release|x86.ActiveCfg = Release|Win32 + {8C1934F5-BFA2-4CF2-8A40-A6C0CA1A1661}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {CA1CD6B1-E5B8-4031-A3BE-BCFCBAE43EEA} + SolutionGuid = {A7E782AE-075F-4E18-A7BA-D5DC29F528C9} EndGlobalSection EndGlobal diff --git a/Overlay/Overlay.vcxproj b/Overlay/Overlay.vcxproj index 73ba7eb..d131ad9 100644 --- a/Overlay/Overlay.vcxproj +++ b/Overlay/Overlay.vcxproj @@ -1,6 +1,14 @@ + + Debug + Win32 + + + Release + Win32 + Debug x64 @@ -12,18 +20,30 @@ 16.0 - {68C049A1-7EA4-45D2-942C-7710AF16B1FA} - Overlay + Win32Proj + {8c1934f5-bfa2-4cf2-8a40-a6c0ca1a1661} + overlay 10.0 - Overlay + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + Application true v143 Unicode - false Application @@ -31,13 +51,18 @@ v143 true Unicode - false + + + + + + @@ -45,37 +70,64 @@ - - overlay - - + Level3 - Disabled true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) true - Windows + Console + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true Level3 - MaxSpeed true true true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) true Windows true true + true - + diff --git a/Overlay/Overlay.vcxproj.filters b/Overlay/Overlay.vcxproj.filters index 4327830..ef66db6 100644 --- a/Overlay/Overlay.vcxproj.filters +++ b/Overlay/Overlay.vcxproj.filters @@ -1,6 +1,22 @@  - + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Исходные файлы + \ No newline at end of file diff --git a/Overlay/Source.cpp b/Overlay/Source.cpp new file mode 100644 index 0000000..c7d7552 --- /dev/null +++ b/Overlay/Source.cpp @@ -0,0 +1,94 @@ +#include +#include +#include +#pragma comment(lib, "dwmapi.lib") + +const MARGINS margins = { -1 ,-1, -1, -1 }; +const wchar_t g_szClassName[] = L"overlay"; + +bool isVisible = true; + +LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + switch (msg) + { + case WM_HOTKEY: + if (wParam == 1) // + { + isVisible = !isVisible; // isVisible + ShowWindow(hwnd, isVisible ? SW_SHOW : SW_HIDE); // / isVisible + } + break; + case WM_PAINT: + { + PAINTSTRUCT ps; + HDC hdc = BeginPaint(hwnd, &ps); + TEXTMETRIC tm; + GetTextMetrics(hdc, &tm); + int x = 10; + int y = tm.tmHeight + 10; + TextOut(hdc, x, y, L"By vos9", 7); + EndPaint(hwnd, &ps); + } + break; + case WM_DESTROY: + PostQuitMessage(0); + break; + default: + return DefWindowProc(hwnd, msg, wParam, lParam); + } + return 0; +} + + + +int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) +{ + WNDCLASSEX wc; + HWND hwnd; + MSG Msg; + + // + wc.cbSize = sizeof(WNDCLASSEX); + wc.style = CS_HREDRAW | CS_VREDRAW; + wc.lpfnWndProc = WndProc; // + wc.cbClsExtra = 0; + wc.cbWndExtra = 0; + wc.hInstance = hInstance; + wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); + wc.hCursor = LoadCursor(NULL, IDC_ARROW); + wc.hbrBackground = (HBRUSH)(RGB(0, 0, 0)); + wc.lpszMenuName = NULL; + wc.lpszClassName = g_szClassName; + wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION); + + RegisterClassEx(&wc); + + // + hwnd = CreateWindowEx( + WS_EX_LAYERED | WS_EX_TRANSPARENT | WS_EX_TOOLWINDOW | WS_EX_TOPMOST, // <--- WS_EX_TOOLWINDOW + g_szClassName, + g_szClassName, + WS_POPUP | WS_VISIBLE, + 0, 0, 1920, 1080, + NULL, NULL, hInstance, NULL); + + SetLayeredWindowAttributes(hwnd, RGB(0, 0, 0), 255, LWA_ALPHA); + DwmExtendFrameIntoClientArea(hwnd, &margins); + + // + RegisterHotKey(hwnd, 1, MOD_ALT, 0x5A); // 0x5A Z + + // + while (GetMessage(&Msg, NULL, 0, 0) > 0) + { + TranslateMessage(&Msg); + DispatchMessage(&Msg); + } + + // + UnregisterHotKey(hwnd, 1); + + exit(0); + return Msg.wParam; +} \ No newline at end of file