This commit is contained in:
EmsiaetKadosh
2025-01-14 19:51:08 +08:00
parent 2b8f8121f8
commit 4f455ca6ad
6 changed files with 103 additions and 29 deletions
+25 -21
View File
@@ -1,13 +1,4 @@
#include <Windows.h>
#include <minwindef.h>
#include <windef.h>
#include <wingdi.h>
#include <winuser.h>
#include <Uxtheme.h>
#include <iostream>
#include <dwmapi.h>
#include "hbp.h"
#include "InteractManager.h"
@@ -20,6 +11,20 @@ LRESULT __stdcall WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
EndPaint(hwnd, &ps);
break;
}
_LIKELY
case WM_NCHITTEST: {
LRESULT lr = 0;
BOOL r = DwmDefWindowProc(hwnd, uMsg, wParam, lParam, &lr);
return HTCLIENT;
}
case WM_KEYDOWN: interactManager.update(static_cast<int>(wParam), true);
break;
case WM_KEYUP: interactManager.update(static_cast<int>(wParam), false);
break;
case WM_SYSKEYDOWN: interactManager.update(static_cast<int>(wParam), true);
break;
case WM_SYSKEYUP: interactManager.update(static_cast<int>(wParam), false);
break;
case WM_LBUTTONDOWN: interactManager.update(VK_LBUTTON, true);
break;
case WM_RBUTTONDOWN: interactManager.update(VK_RBUTTON, true);
@@ -28,17 +33,14 @@ LRESULT __stdcall WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
break;
case WM_RBUTTONUP: interactManager.update(VK_RBUTTON, false);
break;
_LIKELY
case WM_NCHITTEST: {
LRESULT lr = 0;
BOOL r = DwmDefWindowProc(hwnd, uMsg, wParam, lParam, &lr);
return lr;
}
case WM_MOUSEMOVE: { break; }
case WM_MBUTTONDOWN: interactManager.update(VK_MBUTTON, true);
case WM_MOUSEMOVE: interactManager.updateMouse(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
break;
case WM_MBUTTONDOWN: if (wParam & 0x10) interactManager.update(VK_MBUTTON, true);
break;
case WM_MBUTTONUP: interactManager.update(VK_MBUTTON, false);
break;
case WM_MOUSEWHEEL: interactManager.update(VK_MBUTTON, true);
break;
case WM_COMMAND: std::wcout << L"WM_COMMAND" << std::endl;
break;
case WM_DWMCOMPOSITIONCHANGED: {
@@ -60,16 +62,16 @@ LRESULT __stdcall WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
return 0;
}
case WM_SIZE: switch (wParam) {
case SIZE_RESTORED: break;
case SIZE_MINIMIZED: break;
case SIZE_MAXIMIZED: break;
case SIZE_RESTORED:
case SIZE_MINIMIZED:
case SIZE_MAXIMIZED:
case SIZE_MAXSHOW:
case SIZE_MAXHIDE:
default: break;
}
break;
case WM_ACTIVATE: {
MARGINS margins{
constexpr MARGINS margins{
.cxLeftWidth = 0,
.cxRightWidth = 0,
.cyTopHeight = 0,
@@ -91,6 +93,7 @@ LRESULT __stdcall WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
int __stdcall wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow) {
AllocConsole();
freopen("CONOUT$", "w", stdout);
WNDCLASSEX wc = { 0 };
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = CS_HREDRAW | CS_VREDRAW;
@@ -104,6 +107,7 @@ int __stdcall wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCm
wc.lpszMenuName = L"None";
wc.lpszClassName = ApplicationName.c_str();
if (!RegisterClassExW(&wc)) return FALSE;
if (!SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE)) std::wcout << L"SetProcessDpiAwarenessContext failed. LastError: " << GetLastError() << std::endl;
MainInstance = hInstance;
MainWindowHandle = CreateWindowExW(0, wc.lpszClassName, wc.lpszClassName, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, nullptr, nullptr, hInstance, nullptr);
ShowWindow(MainWindowHandle, nCmdShow);