-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathMain.cpp
More file actions
75 lines (55 loc) · 1.7 KB
/
Main.cpp
File metadata and controls
75 lines (55 loc) · 1.7 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <Windows.h>
#include <CommCtrl.h>
#include <iostream>
#include "WindowManagement\resource.h"
#include "WindowManagement\MainWindow.h"
#include "WindowManagement\RedirectIOToConsole.h"
using namespace std;
int WINAPI wWinMain( HINSTANCE hInst , HINSTANCE , PWSTR pCmdLine , int nCmdShow )
{
int exitCode;
wchar_t name[(MAX_LENGTH-2)/2];
wchar_t version[(MAX_LENGTH-2)/2];
wchar_t namePversion[MAX_LENGTH];
MSG msg;
int mainH =823+58 , mainW = 1231+16;
if ( wcsstr(pCmdLine,L"-debug") )
RedirectIOToConsole();
LoadStringW(hInst,IDS_APPLICATION_NAME, name,(MAX_LENGTH-2)/2);
LoadStringW(hInst,IDS_APPLICATION_VERSION,version,(MAX_LENGTH-2)/2);
wcscpy_s(namePversion,(MAX_LENGTH-2)/2,name);
namePversion[wcslen(name)] = L' ';
namePversion[wcslen(name)+1] = L'v';
wcscpy_s(namePversion+wcslen(name)+2,(MAX_LENGTH-2)/2,version);
try
{
MainWindow main(hInst,namePversion,mainW,mainH);
INITCOMMONCONTROLSEX commonCtrls;
commonCtrls.dwSize = sizeof(commonCtrls);
commonCtrls.dwICC = ICC_BAR_CLASSES;
InitCommonControlsEx(&commonCtrls);
main.create();
while ( GetMessage(&msg, (HWND) NULL, 0, 0) > 0 )
{
HWND activeHandle = GetActiveWindow();
if ( !( (GetWindowLongPtr(activeHandle, GWL_EXSTYLE) & WS_EX_CONTROLPARENT) && IsDialogMessage(activeHandle, &msg) ) )
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
exitCode = msg.wParam;
}
catch ( exception& e )
{
cerr << e.what() << endl;
MessageBoxW(NULL,L"A runtime error has occured. Terminating",L"Error",MB_ICONWARNING | MB_OK);
exitCode = -1;
}
if ( wcsstr(pCmdLine,L"-debug") )
system("PAUSE");
exit(exitCode);
}