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

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