h2Gui

一个呕心沥血的Gui框架


Win32窗口

<pre><code class="language-cpp">#include &amp;lt;Windows.h&amp;gt; LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_CREATE: { break; } case WM_PAINT: { break; } case WM_LBUTTONDOWN: { break; } case WM_DESTROY: PostQuitMessage(0); return 0; default: break; } return DefWindowProcW(hWnd, uMsg, wParam, lParam); } int main() { // 注册窗口类 WNDCLASSEXW wcex = { 0 }; wcex.cbSize = sizeof(WNDCLASSEXW); wcex.style = CS_HREDRAW | CS_VREDRAW; wcex.lpfnWndProc = [](HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) -&amp;gt; LRESULT { SetWindowLongPtrW(hWnd, GWLP_WNDPROC, (LONG_PTR)WndProc); // 指向新的窗口过程 return WndProc(hWnd, uMsg, wParam, lParam); }; wcex.hInstance = GetModuleHandleW(nullptr); wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); wcex.hCursor = LoadCursorW(nullptr, IDC_ARROW); wcex.lpszClassName = L&amp;quot;Window.ClassName&amp;quot;; RegisterClassExW(&amp;amp;wcex); // 创建窗口 HWND hWnd = CreateWindowExW( 0, L&amp;quot;Window.ClassName&amp;quot;, L&amp;quot;Window.Test&amp;quot;, WS_OVERLAPPEDWINDOW | WS_VISIBLE, 200, 200, 800, 600, nullptr, nullptr, GetModuleHandleW(nullptr), nullptr); UpdateWindow(hWnd); // 建立消息循环 MSG msg = { 0 }; while (GetMessageW(&amp;amp;msg, nullptr, 0, 0) &amp;gt; 0) { TranslateMessage(&amp;amp;msg); DispatchMessageW(&amp;amp;msg); } return (int)msg.wParam; } </code></pre>

页面列表

ITEM_HTML