Skip to content

Commit

Permalink
Restore the window if error popped.
Browse files Browse the repository at this point in the history
  • Loading branch information
prsyahmi committed Jun 4, 2017
1 parent 86c97e5 commit 865bebb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion GpuRamDrive/EntryPoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}

Expand Down
6 changes: 6 additions & 0 deletions GpuRamDrive/GpuRamGui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions GpuRamDrive/GpuRamGui.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 865bebb

Please sign in to comment.