diff --git a/cmake/build_helpers.cmake b/cmake/build_helpers.cmake index 2323997c6..f38f92140 100644 --- a/cmake/build_helpers.cmake +++ b/cmake/build_helpers.cmake @@ -114,11 +114,7 @@ macro(configurePackageCreation) endif() if (WIN32) - if (CMAKE_BUILD_TYPE EQUAL "DEBUG") - set(application_type WIN32) - else () - set(application_type) - endif () + set(application_type) set(imhex_icon "${CMAKE_SOURCE_DIR}/res/resource.rc") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,--allow-multiple-definition") set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wl,-subsystem,windows") diff --git a/include/window.hpp b/include/window.hpp index 1865fd54f..502db7a71 100644 --- a/include/window.hpp +++ b/include/window.hpp @@ -23,12 +23,7 @@ namespace hex { void loop(); - friend void *ImHexSettingsHandler_ReadOpenFn(ImGuiContext *ctx, ImGuiSettingsHandler *, const char *); - friend void ImHexSettingsHandler_ReadLine(ImGuiContext*, ImGuiSettingsHandler *handler, void *, const char* line); - friend void ImHexSettingsHandler_ApplyAll(ImGuiContext *ctx, ImGuiSettingsHandler *handler); - friend void ImHexSettingsHandler_WriteAll(ImGuiContext* ctx, ImGuiSettingsHandler *handler, ImGuiTextBuffer *buf); - - void setFont(const std::filesystem::path &font_path); + static void initNative(); private: void setupNativeWindow(); @@ -47,6 +42,12 @@ namespace hex { void deinitGLFW(); void deinitImGui(); + friend void *ImHexSettingsHandler_ReadOpenFn(ImGuiContext *ctx, ImGuiSettingsHandler *, const char *); + friend void ImHexSettingsHandler_ReadLine(ImGuiContext*, ImGuiSettingsHandler *handler, void *, const char* line); + friend void ImHexSettingsHandler_WriteAll(ImGuiContext* ctx, ImGuiSettingsHandler *handler, ImGuiTextBuffer *buf); + + void setFont(const std::filesystem::path &font_path); + GLFWwindow* m_window = nullptr; float m_globalScale = 1.0F, m_fontScale = 1.0F; diff --git a/source/main.cpp b/source/main.cpp index cec132da3..1bb083072 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -5,12 +5,13 @@ #include "init/splash_window.hpp" #include "init/tasks.hpp" - int main(int argc, char **argv) { using namespace hex; // Initialization { + Window::initNative(); + init::WindowSplash splashWindow(argc, argv); for (const auto &[name, task] : init::getInitTasks()) diff --git a/source/window/linux_window.cpp b/source/window/linux_window.cpp index 1e09780aa..ec6ae8d69 100644 --- a/source/window/linux_window.cpp +++ b/source/window/linux_window.cpp @@ -4,6 +4,10 @@ namespace hex { + void Window::initNative() { + + } + void Window::setupNativeWindow() { } diff --git a/source/window/macos_window.cpp b/source/window/macos_window.cpp index 6fa7badb2..0415176d7 100644 --- a/source/window/macos_window.cpp +++ b/source/window/macos_window.cpp @@ -4,6 +4,10 @@ namespace hex { + void Window::initNative() { + + } + void Window::setupNativeWindow() { } diff --git a/source/window/win_window.cpp b/source/window/win_window.cpp index 69a44a6e1..9693594a7 100644 --- a/source/window/win_window.cpp +++ b/source/window/win_window.cpp @@ -122,16 +122,31 @@ return CallWindowProc((WNDPROC)oldWndProc, hwnd, uMsg, wParam, lParam); } + + void Window::initNative() { + auto hConsoleWindow = ::GetConsoleWindow(); + ::ShowWindow(hConsoleWindow, FALSE); + + auto hConsole = ::GetStdHandle(STD_OUTPUT_HANDLE); + if (hConsole != INVALID_HANDLE_VALUE) { + DWORD mode = 0; + if (::GetConsoleMode(hConsole, &mode)) { + mode |= ENABLE_VIRTUAL_TERMINAL_PROCESSING; + ::SetConsoleMode(hConsole, mode); + } + } + } + void Window::setupNativeWindow() { auto hwnd = glfwGetWin32Window(this->m_window); - oldWndProc = SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)wndProcImHex); + oldWndProc = ::SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)wndProcImHex); MARGINS borderless = {1,1,1,1}; - DwmExtendFrameIntoClientArea(hwnd, &borderless); + ::DwmExtendFrameIntoClientArea(hwnd, &borderless); - SetWindowPos(hwnd, nullptr, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED | SWP_ASYNCWINDOWPOS | SWP_NOSIZE | SWP_NOMOVE); - SetWindowLong(hwnd, GWL_STYLE, GetWindowLong(hwnd, GWL_STYLE) | WS_POPUP | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_CAPTION | WS_SYSMENU); + ::SetWindowPos(hwnd, nullptr, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED | SWP_ASYNCWINDOWPOS | SWP_NOSIZE | SWP_NOMOVE); + ::SetWindowLong(hwnd, GWL_STYLE, GetWindowLong(hwnd, GWL_STYLE) | WS_POPUP | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_CAPTION | WS_SYSMENU); } void Window::updateNativeWindow() {