From 56f9d8a6f3794666e75275a48314ff0e59d79b9c Mon Sep 17 00:00:00 2001 From: qtkite Date: Mon, 16 Aug 2021 21:41:26 +1000 Subject: [PATCH] wndproc --- src/defender-control/gui.cpp | 34 ++++++++++++++++++++++++++++++++++ src/defender-control/gui.hpp | 4 ++++ 2 files changed, 38 insertions(+) diff --git a/src/defender-control/gui.cpp b/src/defender-control/gui.cpp index 7e61ee6..656dbf8 100644 --- a/src/defender-control/gui.cpp +++ b/src/defender-control/gui.cpp @@ -2,8 +2,42 @@ namespace gui { + LRESULT CALLBACK window_proc(const HWND hwnd, const UINT msg, + const WPARAM wParam, const LPARAM lParam) + { + if (ImGui_ImplWin32_WndProcHandler(hwnd, msg, wParam, lParam)) + return true; + + // TODO: + switch (msg) + { + case WM_SIZE: + return 0; + case WM_SYSCOMMAND: + return 0; + case WM_DESTROY: + PostQuitMessage(0); + return 0; + } + + return DefWindowProcA(hwnd, msg, wParam, lParam); + } + int main() { + WNDCLASSEXW wc{ + sizeof(WNDCLASSEXW), CS_CLASSDC, window_proc, 0L, 0L, + GetModuleHandle(0), NULL, NULL, NULL, NULL, L"dx", NULL + }; + + RegisterClassExW(&wc); + + auto hwnd = CreateWindowExW( + 0, wc.lpszClassName, L"dx", WS_OVERLAPPEDWINDOW, 0, 0, 1920, 1080, 0, 0, wc.hInstance, 0 + ); + + // TODO: + // return EXIT_SUCCESS; } diff --git a/src/defender-control/gui.hpp b/src/defender-control/gui.hpp index 7f84dee..94ecc51 100644 --- a/src/defender-control/gui.hpp +++ b/src/defender-control/gui.hpp @@ -1,5 +1,9 @@ #pragma once #include +#include + +extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler( + HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); namespace gui {