-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
152 lines (138 loc) · 3.51 KB
/
main.cpp
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
/*
COPYRIGHT (c) ROMAN RATASHNIUK 2015-2016
*/
#define ISOLATION_AWARE_ENABLED 1
#define _UNICODE
#include <windows.h>
#include <Richedit.h>
#include "translations.h"
#include "resource1.h"
#include "mainPrefs.h"
#include "stdincld.h"
#include "globalVars.h"
//APP DEFINED MENU IDS
#include "menuids.h"
#include "editcontrol.h"
#include "appconst.h"
#include "mainWindowProc.h"
#include "splashScreen.h"
#include "toolbarControl.h"
//default env vals
#include "service.h"
#include "contextMenu.h"
#include "systemCheck.h"
#include "recentFiles.h"
//extern MAINPREFS settings;
WPARAM posX, posY;
WPARAM mainWidth, mainHeight;
void setEnvVars(int _mainWidth=wpInitWidth, int _mainHeight=wpInitHeight,
int _posX=wpInitPosX, int _posY=wpInitPosY)
{
mainWidth = _mainWidth;
mainHeight = _mainHeight;
posX = _posX;
posY = _posY;
currentWidth = mainWidth;
currentHeight = mainHeight;
currentPosX = posX;
currentPosY = posY;
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
//if (!chkComCtlVersion())
{
//MessageBox(NULL,errorMessages_ENG[0],_T("Error"),MB_ICONERROR);
//return 0;
}
//loadAppSmIcon();
if (binary::chkIfConfigExists())
{
binary::loadMainPrefs();
}
else
{
binary::setDefaultPrefs();
binary::saveMainPrefs();
}
binary::loadMainPrefs();
manualOverride::saveMainPrefs(); //not done yet
OPENMODE = 1; // 1 - text, 2 - rtf
//HWND hwnd = NULL;
if (settings.bRememberLastSizeByUser)
{
//loading usr specified parameters
setEnvVars(settings.iUsrLastWidth, settings.iUsrLastHeight, settings.iUsrLastXPos, settings.iUsrLastYPos);
}
else
{
//going with default values for width height posx and posy
setEnvVars();
}
//NO MENU FILLING ON STARTUP PLS
if (chkIfRecentFilesExists())
{
loadRecentFiles();
bRecentFilesExist = true;
}
currRecentAddStart = IDM_REC_CLEAR + 1;
//setDefaultPrefs(); //for now
MSG message;
WNDCLASSEX wc = {0}; //nullifying the struct
wc.cbSize = sizeof(wc);
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.lpszClassName = szAppClass;
wc.hInstance = hInstance;
wc.hbrBackground = GetSysColorBrush(COLOR_3DFACE);
wc.lpszMenuName = NULL;
wc.lpfnWndProc = mainWindowProcedure;
//wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hCursor = plainCursor;
//wc.hIconSm = LoadIcon(NULL, IDI_ASTERISK);
mainAppIcon = (HICON)LoadImage(hInstance, MAKEINTRESOURCE(IDI_MAINAPPICON), IMAGE_ICON, 0, 0, NULL);
appSetsIcon = (HICON)LoadImage(hInstance, MAKEINTRESOURCE(IDI_APPSETSICON), IMAGE_ICON, 0, 0, NULL);
wc.hIconSm = mainAppIcon;
wc.hIcon = mainAppIcon;
//wc.hIconSm = (HICON)LoadImage(ghInstance,_T("texEditIcon32x32.ico"),IMAGE_ICON,32,32,LR_LOADFROMFILE);
if (!RegisterClassEx(&wc))
{
MessageBox(NULL, _T("Window class registration failed"), _T("Error"), MB_ICONERROR);
return false;
}
ghInstance = hInstance;
hwnd = CreateWindowEx
(
0,
wc.lpszClassName,
szAppName,
WS_OVERLAPPEDWINDOW|WS_CLIPCHILDREN,
currentPosX,
currentPosY,
currentWidth,
currentHeight,
NULL,
NULL,
hInstance,
NULL
);
ShowWindow(hwnd, nCmdShow);
UpdateWindow(hwnd);
//MessageBox(hwnd, commDlg[1], commDlgMsgWarnInfoCaptions_EN[0], MB_YESNO | MB_ICONINFORMATION);
while (GetMessage(&message, NULL, 0, 0))
{
//process msg here if needed
//if (!IsDialogMessage(findDlg, &message))
//{
if (message.message == WM_RBUTTONDOWN)
{
createContextMenu(hwnd, message.lParam);
}
TranslateMessage(&message);
DispatchMessage(&message);
//}
}
return (int)(message.wParam);
//return 0;
}