-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWinMain.cpp
More file actions
37 lines (32 loc) · 1023 Bytes
/
WinMain.cpp
File metadata and controls
37 lines (32 loc) · 1023 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include "App.h" // wrapper for winapi
#include <stdio.h>
int CALLBACK WinMain( // CALLBACK is stdcall convention used by windows
HINSTANCE hInstance, // handle to current instance
HINSTANCE hPrevInstance, // nullptr
LPSTR lpCmdLine, // string pointer to cmd line arguments (non-parsed)
int nCmdShow) // window property on startup
{
// Console attaching snippet
AllocConsole();
FILE* fp;
freopen_s(&fp, "CONOUT$", "w", stdout);
printf("Hello from GUI app with console!\n");
try {
return App{}.Begin();
}
// ------------ Exception Handling ------------ //
catch ( const SmflmException& e) // exception handling
{
MessageBox(nullptr, e.what(), e.GetType(), MB_OK | MB_ICONEXCLAMATION);
}
catch (const std::exception& e)
{
MessageBox(nullptr, e.what(), "Standard Exception", MB_OK | MB_ICONEXCLAMATION);
}
catch (...)
{
MessageBox(nullptr, "No Details Available", "Unknown Exception", MB_OK | MB_ICONEXCLAMATION);
}
// ---------- Exception Handling End ---------- //
return -1;
}