1
0
mirror of synced 2025-01-18 00:56:49 +01:00

sys: Enable logging colors on Windows, hide console

Console log can still be seen now when running ImHex through the console but the window won't pop up by default anymore
This commit is contained in:
WerWolv 2021-08-22 20:24:42 +02:00
parent 66f94a452d
commit 2362e7a11f
6 changed files with 37 additions and 16 deletions

View File

@ -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")

View File

@ -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;

View File

@ -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())

View File

@ -4,6 +4,10 @@
namespace hex {
void Window::initNative() {
}
void Window::setupNativeWindow() {
}

View File

@ -4,6 +4,10 @@
namespace hex {
void Window::initNative() {
}
void Window::setupNativeWindow() {
}

View File

@ -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() {