From 2b8f8121f82f591e14fd975a25b4424c7a411dd5 Mon Sep 17 00:00:00 2001 From: EmsiaetKadosh Date: Tue, 14 Jan 2025 15:35:35 +0800 Subject: [PATCH] Changes --- .clang-format | 8 +- .idea/.gitignore | 8 ++ CMakeLists.txt | 5 +- InteractManager.cpp | 265 ++++++++++++++++++++++++++++++++++++++++++++ InteractManager.h | 37 +++++++ def.h | 30 +++++ hbp.h | 32 ++++++ main.cpp | 103 +++++++---------- 8 files changed, 422 insertions(+), 66 deletions(-) create mode 100644 .idea/.gitignore create mode 100644 InteractManager.cpp create mode 100644 InteractManager.h create mode 100644 def.h create mode 100644 hbp.h diff --git a/.clang-format b/.clang-format index daaa1e9..48949df 100644 --- a/.clang-format +++ b/.clang-format @@ -7,7 +7,7 @@ BasedOnStyle: llvm # WIN = Whatever. If Needed, you can change it as you like. # WSO = Whatever. If needed, you can change, but keep same in One code block. # BTW = Better This but you can change as you like, Whatever. -# +# # 在标识后紧跟默认值,再后跟所有可能取值 Language: Cpp @@ -78,7 +78,7 @@ BraceWrapping: BeforeElse: true BeforeLambdaBody: false # BTW false, true BeforeWhile: true - # BTW false, true + # BTW false, true IndentBraces: false # 仅当花括号换行时有效 SplitEmptyFunction: false # 如果为true,空函数右花括号}强制换行 SplitEmptyRecord: false # 如果为true,空类型class union union...右花括号}强制换行 @@ -149,7 +149,7 @@ IncludeBlocks: Preserve IndentCaseLabels: true IndentExternBlock: Indent -IndentWidth: 4 +IndentWidth: 2 InsertNewlineAtEOF: true KeepEmptyLinesAtEOF: true LineEnding: CRLF @@ -169,7 +169,7 @@ SpaceAfterTemplateKeyword: false # WSO SpaceAroundPointerQualifiers: Before # WSO SpacesBeforeTrailingComments: 0 # Better 1; 0 ok, 2+ better not. Standard: Latest -TabWidth: 4 # 4 or 2, WSO +TabWidth: 2 # 4 or 2, WSO # UseTab possible values: # Never # ForIndentation diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/CMakeLists.txt b/CMakeLists.txt index 28e34a8..10125be 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,7 +15,10 @@ set(CMAKE_WIN32_EXECUTABLE true) include(CTest) enable_testing() -add_executable(${PROJECT_NAME} main.cpp) +add_executable(${PROJECT_NAME} main.cpp + def.h + InteractManager.cpp + InteractManager.h) set(CPACK_PROJECT_NAME ${PROJECT_NAME}) set(CPACK_PROJECT_VERSION ${PROJECT_VERSION}) include(CPack) diff --git a/InteractManager.cpp b/InteractManager.cpp new file mode 100644 index 0000000..d5e60f5 --- /dev/null +++ b/InteractManager.cpp @@ -0,0 +1,265 @@ +// +// Created by EmsiaetKadosh on 25-1-14. +// + +#include "InteractManager.h" + +InteractManager::InteractManager() { + keyStatus[0x00].name = L"NONE"; + keyStatus[0x01].name = L"LeftButton"; + keyStatus[0x02].name = L"RightButton"; + keyStatus[0x03].name = L"Cancel"; + keyStatus[0x04].name = L"MiddleButton"; + keyStatus[0x05].name = L"XButton1"; + keyStatus[0x06].name = L"XButton2"; + keyStatus[0x07].name = L"None"; + keyStatus[0x08].name = L"Backspace"; + keyStatus[0x09].name = L"Tab"; + keyStatus[0x0D].name = L"Enter"; + keyStatus[0x0A].name = L"None"; + keyStatus[0x0B].name = L"None"; + keyStatus[0x0C].name = L"Clear"; + keyStatus[0x0D].name = L"Enter"; + keyStatus[0x0E].name = L"None"; + keyStatus[0x0F].name = L"None"; + keyStatus[0x10].name = L"Shift"; + keyStatus[0x11].name = L"Ctrl"; + keyStatus[0x12].name = L"Alt"; + keyStatus[0x13].name = L"Pause"; + keyStatus[0x14].name = L"CapsLock"; + keyStatus[0x15].name = L"IME-KanaHangul"; + keyStatus[0x16].name = L"IME-ON"; + keyStatus[0x17].name = L"IME-Junja"; + keyStatus[0x18].name = L"IME-Final"; + keyStatus[0x19].name = L"IME-HanjaKanji"; + keyStatus[0x1A].name = L"IME-OFF"; + keyStatus[0x1B].name = L"Escape"; + keyStatus[0x1C].name = L"IME-Convert"; + keyStatus[0x1D].name = L"IME-NonConvert"; + keyStatus[0x1E].name = L"IME-Accept"; + keyStatus[0x1F].name = L"IME-ModeChange"; + keyStatus[0x20].name = L"Space"; + keyStatus[0x21].name = L"PageUp"; + keyStatus[0x22].name = L"PageDown"; + keyStatus[0x23].name = L"End"; + keyStatus[0x24].name = L"Home"; + keyStatus[0x25].name = L"Left"; + keyStatus[0x26].name = L"Up"; + keyStatus[0x27].name = L"Right"; + keyStatus[0x28].name = L"Down"; + keyStatus[0x29].name = L"Select"; + keyStatus[0x2A].name = L"Print"; + keyStatus[0x2B].name = L"Execute"; + keyStatus[0x2C].name = L"PrintScreen"; + keyStatus[0x2D].name = L"Insert"; + keyStatus[0x2E].name = L"Delete"; + keyStatus[0x2F].name = L"Help"; + keyStatus[0x30].name = L"0"; + keyStatus[0x31].name = L"1"; + keyStatus[0x32].name = L"2"; + keyStatus[0x33].name = L"3"; + keyStatus[0x34].name = L"4"; + keyStatus[0x35].name = L"5"; + keyStatus[0x36].name = L"6"; + keyStatus[0x37].name = L"7"; + keyStatus[0x38].name = L"8"; + keyStatus[0x39].name = L"9"; + keyStatus[0x3A].name = L"None"; + keyStatus[0x3B].name = L"None"; + keyStatus[0x3C].name = L"None"; + keyStatus[0x3D].name = L"None"; + keyStatus[0x3E].name = L"None"; + keyStatus[0x3F].name = L"None"; + keyStatus[0x40].name = L"None"; + keyStatus[0x41].name = L"A"; + keyStatus[0x42].name = L"B"; + keyStatus[0x43].name = L"C"; + keyStatus[0x44].name = L"D"; + keyStatus[0x45].name = L"E"; + keyStatus[0x46].name = L"F"; + keyStatus[0x47].name = L"G"; + keyStatus[0x48].name = L"H"; + keyStatus[0x49].name = L"I"; + keyStatus[0x4A].name = L"J"; + keyStatus[0x4B].name = L"K"; + keyStatus[0x4C].name = L"L"; + keyStatus[0x4D].name = L"M"; + keyStatus[0x4E].name = L"N"; + keyStatus[0x4F].name = L"O"; + keyStatus[0x50].name = L"P"; + keyStatus[0x51].name = L"Q"; + keyStatus[0x52].name = L"R"; + keyStatus[0x53].name = L"S"; + keyStatus[0x54].name = L"T"; + keyStatus[0x55].name = L"U"; + keyStatus[0x56].name = L"V"; + keyStatus[0x57].name = L"W"; + keyStatus[0x58].name = L"X"; + keyStatus[0x59].name = L"Y"; + keyStatus[0x5A].name = L"Z"; + keyStatus[0x5B].name = L"LeftWindows"; + keyStatus[0x5C].name = L"RightWindows"; + keyStatus[0x5D].name = L"Applications"; + keyStatus[0x5E].name = L"None"; + keyStatus[0x5F].name = L"Sleep"; + keyStatus[0x60].name = L"NUMPAD-0"; + keyStatus[0x61].name = L"NUMPAD-1"; + keyStatus[0x62].name = L"NUMPAD-2"; + keyStatus[0x63].name = L"NUMPAD-3"; + keyStatus[0x64].name = L"NUMPAD-4"; + keyStatus[0x65].name = L"NUMPAD-5"; + keyStatus[0x66].name = L"NUMPAD-6"; + keyStatus[0x67].name = L"NUMPAD-7"; + keyStatus[0x68].name = L"NUMPAD-8"; + keyStatus[0x69].name = L"NUMPAD-9"; + keyStatus[0x6A].name = L"*"; + keyStatus[0x6B].name = L"+"; + keyStatus[0x6C].name = L"·"; + keyStatus[0x6D].name = L"-"; + keyStatus[0x6E].name = L"."; + keyStatus[0x6F].name = L"/"; + keyStatus[0x70].name = L"F1"; + keyStatus[0x71].name = L"F2"; + keyStatus[0x72].name = L"F3"; + keyStatus[0x73].name = L"F4"; + keyStatus[0x74].name = L"F5"; + keyStatus[0x75].name = L"F6"; + keyStatus[0x76].name = L"F7"; + keyStatus[0x77].name = L"F8"; + keyStatus[0x78].name = L"F9"; + keyStatus[0x79].name = L"F10"; + keyStatus[0x7A].name = L"F11"; + keyStatus[0x7B].name = L"F12"; + keyStatus[0x7C].name = L"F13"; + keyStatus[0x7D].name = L"F14"; + keyStatus[0x7E].name = L"F15"; + keyStatus[0x7F].name = L"F16"; + keyStatus[0x80].name = L"F17"; + keyStatus[0x81].name = L"F18"; + keyStatus[0x82].name = L"F19"; + keyStatus[0x83].name = L"F20"; + keyStatus[0x84].name = L"F21"; + keyStatus[0x85].name = L"F22"; + keyStatus[0x86].name = L"F23"; + keyStatus[0x87].name = L"F24"; + keyStatus[0x88].name = L"None"; + keyStatus[0x89].name = L"None"; + keyStatus[0x8A].name = L"None"; + keyStatus[0x8B].name = L"None"; + keyStatus[0x8C].name = L"None"; + keyStatus[0x8D].name = L"None"; + keyStatus[0x8E].name = L"None"; + keyStatus[0x8F].name = L"None"; + keyStatus[0x90].name = L"NumLock"; + keyStatus[0x91].name = L"ScrollLock"; + keyStatus[0x92].name = L"None"; + keyStatus[0x93].name = L"None"; + keyStatus[0x94].name = L"None"; + keyStatus[0x95].name = L"None"; + keyStatus[0x96].name = L"None"; + keyStatus[0x97].name = L"None"; + keyStatus[0x98].name = L"None"; + keyStatus[0x99].name = L"None"; + keyStatus[0x9A].name = L"None"; + keyStatus[0x9B].name = L"None"; + keyStatus[0x9C].name = L"None"; + keyStatus[0x9D].name = L"None"; + keyStatus[0x9E].name = L"None"; + keyStatus[0x9F].name = L"None"; + keyStatus[0xA0].name = L"LeftShift"; + keyStatus[0xA1].name = L"RightShift"; + keyStatus[0xA2].name = L"LeftCtrl"; + keyStatus[0xA3].name = L"RightCtrl"; + keyStatus[0xA4].name = L"LeftAlt"; + keyStatus[0xA5].name = L"RightAlt"; + keyStatus[0xA6].name = L"BrowserBack"; + keyStatus[0xA7].name = L"BrowserForward"; + keyStatus[0xA8].name = L"BrowserRefresh"; + keyStatus[0xA9].name = L"BrowserStop"; + keyStatus[0xAA].name = L"BrowserSearch"; + keyStatus[0xAB].name = L"BrowserFavorites"; + keyStatus[0xAC].name = L"BrowserHome"; + keyStatus[0xAD].name = L"VolumeMute"; + keyStatus[0xAE].name = L"VolumeDown"; + keyStatus[0xAF].name = L"VolumeUp"; + keyStatus[0xB0].name = L"MediaNextTrack"; + keyStatus[0xB1].name = L"MediaPrevTrack"; + keyStatus[0xB2].name = L"MediaStop"; + keyStatus[0xB3].name = L"MediaPlayPause"; + keyStatus[0xB4].name = L"LaunchMail"; + keyStatus[0xB5].name = L"LaunchMediaSelect"; + keyStatus[0xB6].name = L"LaunchApp1"; + keyStatus[0xB7].name = L"LaunchApp2"; + keyStatus[0xB8].name = L"None"; + keyStatus[0xB9].name = L"None"; + keyStatus[0xBA].name = L"OEM-1;:"; + keyStatus[0xBB].name = L"OEM+"; + keyStatus[0xBC].name = L"OEM,"; + keyStatus[0xBD].name = L"OEM-"; + keyStatus[0xBE].name = L"OEM."; + keyStatus[0xBF].name = L"OEM-2/?"; + keyStatus[0xC0].name = L"OEM-3`~"; + keyStatus[0xC1].name = L"None"; + keyStatus[0xC2].name = L"None"; + keyStatus[0xC3].name = L"None"; + keyStatus[0xC4].name = L"None"; + keyStatus[0xC5].name = L"None"; + keyStatus[0xC6].name = L"None"; + keyStatus[0xC7].name = L"None"; + keyStatus[0xC8].name = L"None"; + keyStatus[0xC9].name = L"None"; + keyStatus[0xCA].name = L"None"; + keyStatus[0xCB].name = L"None"; + keyStatus[0xCC].name = L"None"; + keyStatus[0xCD].name = L"None"; + keyStatus[0xCE].name = L"None"; + keyStatus[0xCF].name = L"None"; + keyStatus[0xD0].name = L"None"; + keyStatus[0xD1].name = L"None"; + keyStatus[0xD2].name = L"None"; + keyStatus[0xD3].name = L"None"; + keyStatus[0xD4].name = L"None"; + keyStatus[0xD5].name = L"None"; + keyStatus[0xD6].name = L"None"; + keyStatus[0xD7].name = L"None"; + keyStatus[0xD8].name = L"None"; + keyStatus[0xD9].name = L"None"; + keyStatus[0xDA].name = L"None"; + keyStatus[0xDB].name = L"OEM-4{["; + keyStatus[0xDC].name = L"OEM-5|\\"; + keyStatus[0xDD].name = L"OEM-6}]"; + keyStatus[0xDE].name = L"OEM-7'\""; + keyStatus[0xDF].name = L"OEM-8"; + keyStatus[0xE0].name = L"None"; + keyStatus[0xE1].name = L"None"; + keyStatus[0xE2].name = L"OEM-102<>"; + keyStatus[0xE3].name = L"None"; + keyStatus[0xE4].name = L"None"; + keyStatus[0xE5].name = L"IME-ProcessKey"; + keyStatus[0xE6].name = L"None"; + keyStatus[0xE7].name = L"IME-Packet"; + keyStatus[0xE8].name = L"None"; + keyStatus[0xE9].name = L"None"; + keyStatus[0xEA].name = L"None"; + keyStatus[0xEB].name = L"None"; + keyStatus[0xEC].name = L"None"; + keyStatus[0xED].name = L"None"; + keyStatus[0xEE].name = L"None"; + keyStatus[0xEF].name = L"None"; + keyStatus[0xF0].name = L"None"; + keyStatus[0xF1].name = L"None"; + keyStatus[0xF2].name = L"None"; + keyStatus[0xF3].name = L"None"; + keyStatus[0xF4].name = L"None"; + keyStatus[0xF5].name = L"None"; + keyStatus[0xF6].name = L"Attn"; + keyStatus[0xF7].name = L"CrSel"; + keyStatus[0xF8].name = L"ExSel"; + keyStatus[0xF9].name = L"ErEof"; + keyStatus[0xFA].name = L"Play"; + keyStatus[0xFB].name = L"Zoom"; + keyStatus[0xFC].name = L"None"; + keyStatus[0xFD].name = L"PA1"; + keyStatus[0xFE].name = L"OEM-Clear"; +} + diff --git a/InteractManager.h b/InteractManager.h new file mode 100644 index 0000000..a2c6a82 --- /dev/null +++ b/InteractManager.h @@ -0,0 +1,37 @@ +// +// Created by EmsiaetKadosh on 25-1-14. +// + +#pragma once + +#include "def.h" + +struct KeyStatus { + String name; + unsigned int pressTimes = 0; + bool isPressed = false; + bool notDealt = false; + + [[nodiscard]] String toString() const noexcept { + return L"name: " + name + L" pressTimes: " + std::to_wstring(pressTimes) + L" isPressed"; + } +}; + +class InteractManager { + KeyStatus keyStatus[256]; + +public: + explicit InteractManager(); + + void update(const int keyCode, const bool isPressed) noexcept { + if (keyCode >= 256) return; + keyStatus[keyCode].isPressed = isPressed; + if (isPressed) { + keyStatus[keyCode].pressTimes++; + keyStatus[keyCode].notDealt = true; + } + std::wcout << keyStatus[keyCode].toString() << std::endl; + } +}; + +inline static InteractManager interactManager = InteractManager(); diff --git a/def.h b/def.h new file mode 100644 index 0000000..62dbc4d --- /dev/null +++ b/def.h @@ -0,0 +1,30 @@ +// +// Created by EmsiaetKadosh on 25-1-14. +// + +#pragma once + +#include +#include +#include + +using String = std::wstring; +template, typename Alloc = std::allocator>> using Map = std::map; + +#if false +#ifdef _MSC_VER +#define __FUNCSIGW__ L"" __FUNCSIG__ +#elif defined(__GNUC__) || defined(__clang__) +#define __FUNCSIGW__ L"" __PRETTY_FUNCTION__ +#else +#define __FUNCSIGW__ L"" __func__ +#endif +#endif + +#if false +#define _WINSOCKAPI_ /* 防止winsock.h被引入。winsock.h和winsock2.h冲突。 */ +#include +#endif + +#define NOMINMAX +#include diff --git a/hbp.h b/hbp.h new file mode 100644 index 0000000..cf43745 --- /dev/null +++ b/hbp.h @@ -0,0 +1,32 @@ +#pragma once + +#include "def.h" + + +inline BOOL NewProcess(const String& cmdline) noexcept { + STARTUPINFOW si = { + sizeof(si), nullptr, nullptr, nullptr, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, nullptr, nullptr, nullptr, nullptr + }; + PROCESS_INFORMATION pi{ + nullptr, nullptr, 0, 0 + }; + return CreateProcessW(nullptr, const_cast(cmdline.c_str()), nullptr, nullptr, 0, 0, nullptr, nullptr, &si, &pi); +} + +inline HRESULT RemoveDefaultCaption(const HWND hWnd, const MARGINS* p) noexcept { return DwmExtendFrameIntoClientArea(hWnd, p); } + +inline void ShowConsoleIO() noexcept { + AllocConsole(); + FILE* pCout; + freopen_s(&pCout, "CONOUT$", "w", stdout); + FILE* pCin; + freopen_s(&pCin, "CONIN$", "r", stdin); +} + +inline const String ApplicationName = L"Hyblud Presher"; +inline HINSTANCE MainInstance; +inline HWND MainWindowHandle; + +inline void Initialize() {} + +inline void Finalize() {} diff --git a/main.cpp b/main.cpp index 5062fca..ba51dd7 100644 --- a/main.cpp +++ b/main.cpp @@ -1,67 +1,45 @@ #include -#include -#include #include #include #include #include #include -#include +#include +#include -#include "../CarlbeksLib/iwindows.h" - -#include "core.h" +#include "hbp.h" +#include "InteractManager.h" LRESULT __stdcall WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { - [[likely]] case WM_PAINT: { + _LIKELY + case WM_PAINT: { PAINTSTRUCT ps; - HDC hdc = BeginPaint(hwnd, &ps); // Paint caption - MainWindow.fireRender(); + HDC hdc = BeginPaint(hwnd, &ps);// Paint caption EndPaint(hwnd, &ps); break; } - case WM_LBUTTONDOWN: - MainWindow.fireMouseDown(Carlbeks::UI::MA_LEFT); - MainWindow.fireRender(); + case WM_LBUTTONDOWN: interactManager.update(VK_LBUTTON, true); break; - case WM_RBUTTONDOWN: - MainWindow.fireMouseDown(Carlbeks::UI::MA_RIGHT); - MainWindow.fireRender(); + case WM_RBUTTONDOWN: interactManager.update(VK_RBUTTON, true); break; - case WM_LBUTTONUP: - MainWindow.fireMouseUp(Carlbeks::UI::MA_LEFT); - MainWindow.fireRender(); + case WM_LBUTTONUP: interactManager.update(VK_LBUTTON, false); break; - case WM_RBUTTONUP: - MainWindow.fireMouseUp(Carlbeks::UI::MA_RIGHT); - MainWindow.fireRender(); + case WM_RBUTTONUP: interactManager.update(VK_RBUTTON, false); break; - [[likely]] case WM_NCHITTEST: { - Carlbeks::UI::UIReturn ret = MainWindow.fireMouseMove(); - MainWindow.fireRender(); - if (ret & 0x20) return ret ^ 0x20; - return HTCLIENT; + _LIKELY + case WM_NCHITTEST: { LRESULT lr = 0; BOOL r = DwmDefWindowProc(hwnd, uMsg, wParam, lParam, &lr); return lr; } - [[likely]] case WM_MOUSEMOVE: { - MainWindow.fireMouseMove(); - // MainWindow.fireRender(); + case WM_MOUSEMOVE: { break; } + case WM_MBUTTONDOWN: interactManager.update(VK_MBUTTON, true); break; - } - [[unlikely]] case WM_MBUTTONDOWN: - MainWindow.fireMouseDown(Carlbeks::UI::MA_MID); - MainWindow.fireRender(); + case WM_MBUTTONUP: interactManager.update(VK_MBUTTON, false); break; - [[unlikely]] case WM_MBUTTONUP: - MainWindow.fireMouseUp(Carlbeks::UI::MA_MID); - MainWindow.fireRender(); - break; - [[unlikely]] case WM_COMMAND: - std::wcout << L"WM_COMMAND" << std::endl; + case WM_COMMAND: std::wcout << L"WM_COMMAND" << std::endl; break; case WM_DWMCOMPOSITIONCHANGED: { MARGINS margins{ @@ -70,11 +48,10 @@ LRESULT __stdcall WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { .cyTopHeight = 0, .cyBottomHeight = 0 }; - HRESULT hr = Carlbeks::WindowsInterface::RemoveDefaultCaption(hwnd, &margins); + HRESULT hr = RemoveDefaultCaption(hwnd, &margins); break; } - case WM_NCCALCSIZE: - if (wParam == 1) { + case WM_NCCALCSIZE: if (wParam == 1) { NCCALCSIZE_PARAMS* pncsp = reinterpret_cast(lParam); pncsp->rgrc[0].left = pncsp->rgrc[0].left + 0; pncsp->rgrc[0].top = pncsp->rgrc[0].top + 0; @@ -82,9 +59,14 @@ LRESULT __stdcall WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { pncsp->rgrc[0].bottom = pncsp->rgrc[0].bottom - 0; return 0; } - case WM_SIZE: - MainWindow.fireResize(); - MainWindow.fireRender(); + case WM_SIZE: switch (wParam) { + case SIZE_RESTORED: break; + case SIZE_MINIMIZED: break; + case SIZE_MAXIMIZED: break; + case SIZE_MAXSHOW: + case SIZE_MAXHIDE: + default: break; + } break; case WM_ACTIVATE: { MARGINS margins{ @@ -93,21 +75,22 @@ LRESULT __stdcall WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { .cyTopHeight = 0, .cyBottomHeight = 0 }; - HRESULT hr = Carlbeks::WindowsInterface::RemoveDefaultCaption(hwnd, &margins); - } break; - [[unlikely]] case WM_DESTROY: - PostQuitMessage(0); - return 0; - [[unlikely]] case WM_CREATE: - SetWindowPos(hwnd, NULL, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOOWNERZORDER); // Force post NCCALCSIZE - break; - default: + HRESULT hr = RemoveDefaultCaption(hwnd, &margins); + } break; + _UNLIKELY + case WM_DESTROY: PostQuitMessage(0); + return 0; + _UNLIKELY + case WM_CREATE: SetWindowPos(hwnd, nullptr, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOOWNERZORDER);// Force post NCCALCSIZE + break; + default: break; } return DefWindowProc(hwnd, uMsg, wParam, lParam); } int __stdcall wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow) { + AllocConsole(); WNDCLASSEX wc = { 0 }; wc.cbSize = sizeof(WNDCLASSEX); wc.style = CS_HREDRAW | CS_VREDRAW; @@ -115,26 +98,24 @@ int __stdcall wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCm wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; - wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); - wc.hCursor = LoadCursor(NULL, IDC_ARROW); + wc.hIcon = LoadIcon(nullptr, IDI_APPLICATION); + wc.hCursor = LoadCursor(nullptr, IDC_ARROW); wc.hbrBackground = (HBRUSH) GetStockObject(BLACK_BRUSH); wc.lpszMenuName = L"None"; wc.lpszClassName = ApplicationName.c_str(); if (!RegisterClassExW(&wc)) return FALSE; MainInstance = hInstance; - MainWindowHandle = CreateWindowExW(0, wc.lpszClassName, wc.lpszClassName, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL); + MainWindowHandle = CreateWindowExW(0, wc.lpszClassName, wc.lpszClassName, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, nullptr, nullptr, hInstance, nullptr); ShowWindow(MainWindowHandle, nCmdShow); Initialize(); - MainWindow.fireResize(); HACCEL hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(109)); - MSG msg = { 0 }; - while (GetMessageW(&msg, NULL, 0, 0)) { + MSG msg = { nullptr }; + while (GetMessageW(&msg, nullptr, 0, 0)) { if (!TranslateAcceleratorW(msg.hwnd, hAccelTable, &msg)) { TranslateMessage(&msg); DispatchMessageW(&msg); } } DestroyAcceleratorTable(hAccelTable); - Finalize(); return (int) msg.wParam; }