From 865bebb33dbb0009f4a720099539b95885bc856f Mon Sep 17 00:00:00 2001 From: Syahmi Azhar <prsyahmi@gmail.com> Date: Mon, 5 Jun 2017 06:54:05 +0800 Subject: [PATCH] Restore the window if error popped. --- GpuRamDrive/EntryPoint.cpp | 3 ++- GpuRamDrive/GpuRamGui.cpp | 6 ++++++ GpuRamDrive/GpuRamGui.h | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/GpuRamDrive/EntryPoint.cpp b/GpuRamDrive/EntryPoint.cpp index fa9230e..e945ce0 100644 --- a/GpuRamDrive/EntryPoint.cpp +++ b/GpuRamDrive/EntryPoint.cpp @@ -107,10 +107,11 @@ int APIENTRY wWinMain( } catch (const std::exception& ex) { + gui.RestoreWindow(); if (GetConsoleWindow() == NULL) { MessageBoxA(NULL, ex.what(), "GpuRamDrive error", MB_OK); } - printf("GpuRamDrive exception: %s\n", ex.what()); + fprintf(stderr, "GpuRamDrive exception: %s\n", ex.what()); } } diff --git a/GpuRamDrive/GpuRamGui.cpp b/GpuRamDrive/GpuRamGui.cpp index faf51ab..26a18b0 100644 --- a/GpuRamDrive/GpuRamGui.cpp +++ b/GpuRamDrive/GpuRamGui.cpp @@ -115,6 +115,12 @@ void GpuRamGui::Mount(const std::wstring& device, size_t size, const std::wstrin Edit_SetText(m_CtlMemSize, szTemp); } +void GpuRamGui::RestoreWindow() +{ + ShowWindow(m_hWnd, SW_RESTORE); + SetForegroundWindow(m_hWnd); +} + void GpuRamGui::OnCreate() { SetWindowLongPtr(m_hWnd, GWL_STYLE, GetWindowLongPtr(m_hWnd, GWL_STYLE) & ~WS_SIZEBOX & ~WS_MAXIMIZEBOX); diff --git a/GpuRamDrive/GpuRamGui.h b/GpuRamDrive/GpuRamGui.h index f16711d..4f6cc91 100644 --- a/GpuRamDrive/GpuRamGui.h +++ b/GpuRamDrive/GpuRamGui.h @@ -24,6 +24,7 @@ class GpuRamGui bool Create(HINSTANCE hInst, const std::wstring& title, int nCmdShow); int Loop(); void Mount(const std::wstring& device, size_t size, const std::wstring& driveLetter); + void RestoreWindow(); private: void OnCreate();