forked from OpenKotOR/mdledit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
55 lines (46 loc) · 1.89 KB
/
Copy pathmain.cpp
File metadata and controls
55 lines (46 loc) · 1.89 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#if defined(UNICODE) && !defined(_UNICODE)
#define _UNICODE
#elif defined(_UNICODE) && !defined(UNICODE)
#define UNICODE
#endif
#include "frame.h"
int WINAPI WinMain(HINSTANCE hThisInstance,
HINSTANCE hPrevInstance,
LPSTR lpszArgument, /// This string contains any CLI arguments that were used to run the .exe
int nCmdShow){
(void)hPrevInstance;
try{
MSG messages; /* Here messages to the application are saved */
const std::string sArguments = lpszArgument != nullptr ? std::string(lpszArgument) : std::string();
if(!sArguments.empty()){
Warning("You have run mdledit with arguments, but this is not supported yet!\n\n"
"These are the arguments: " + sArguments);
}
//Creation of window
std::unique_ptr<Frame> winMain(new Frame(hThisInstance));
if(!winMain->Run(nCmdShow)){
return 1; // error
}
/* Run the message loop. It will run until GetMessage() returns 0 */
while(GetMessage (&messages, NULL, 0, 0)){
/* Translate virtual-key messages into character messages */
TranslateMessage(&messages);
/* Send message to WindowProcedure */
DispatchMessage(&messages);
}
//Will only get this far after while is terminated
//Gdiplus::GdiplusShutdown(gdiplusToken);
/* The program return-value is 0 - The value that PostQuitMessage() gave */
return static_cast<int>(messages.wParam);
}
catch(const std::exception & e){
Error(std::string("Unhandled exception:\n\n") + e.what());
std::cout << "Unhandled exception:\n" << e.what() << "\n";
return 1;
}
catch(...){
Error("Unhandled unknown exception.");
std::cout << "Unhandled unknown exception.\n";
return 1;
}
}