-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathMainframe.cpp
More file actions
341 lines (271 loc) · 6.98 KB
/
Mainframe.cpp
File metadata and controls
341 lines (271 loc) · 6.98 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
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
#include "stdafx.h"
#include "mainframe.h"
#include "UIImageAnimate.h"
#include "CircleImageUI.h"
#include "UIVerticalLayoutBK.h"
#include "DBClickLabelUI.h"
#include "../NetTask/PicTransTask.h"
#include "MsgBox/DuiCloseMessageBox.h"
#include "MsgBox/DuiCommMessageBox.h"
#include "UUID.h"
#include "IniHelper.h"
#include "BrowserTabUI.h"
#include "HelpWebWindow.h"
#include "PathBase.h"
#define TIMER_BY_SECOND (WM_USER + 200)
#define TIMER_INTERVAL_BY_SECOND 3000
#define TIMER_DELAYCALL_GETMATERIAL (WM_USER + 210)
#define TIMER_DELAYCALL_GETCOURSELIST (WM_USER + 211)
#define TIMER_DELAYCALL_GETCOURSEINFO (WM_USER + 212)
#define TimerID_bjh 19867
#define TimerID_cookiebjh 19868
CMainframe::CMainframe(void)
{
m_pCloseBtn = NULL;
m_pBtnExitLogin = NULL;
m_pWebLoading = NULL;
m_pWebLoadFail = NULL;
m_pWebpage = NULL;
m_pNickName = NULL;
m_phandImge = NULL;
proom = nullptr;
}
CMainframe::~CMainframe(void)
{
}
LPCTSTR CMainframe::GetWindowClassName()const
{
return L"mainframe";
}
void CMainframe::InitWindow()
{
m_pCloseBtn = static_cast<CButtonUI*>(m_PaintManager.FindControl(L"closebtn"));
m_pMinBtn = static_cast<CButtonUI*>(m_PaintManager.FindControl(L"minbtn"));
m_pMaxBtn = static_cast<CButtonUI*>(m_PaintManager.FindControl(L"maxbtn"));
m_pRefreshBtn = static_cast<CButtonUI*>(m_PaintManager.FindControl(L"refutbtn"));
m_pBtnMaterialMgr = static_cast<CButtonUI*>(m_PaintManager.FindControl(L"downloadMgrBtn"));
m_pBtnMateriaAnimate = static_cast<CImageAnimateUI*>(m_PaintManager.FindControl(L"downloadMgrBtnFrame"));
m_pBtnDevCheck = static_cast<CButtonUI*>(m_PaintManager.FindControl(L"BtnDeviceCheck"));
m_pBtnExitLogin = static_cast<CButtonUI*>(m_PaintManager.FindControl(L"BtnLoginOut"));
m_pVersionLab = static_cast<CLabelUI*>(m_PaintManager.FindControl(L"versionLab"));
m_pLogoVL = static_cast<CHorizontalLayoutUI*>(m_PaintManager.FindControl(L"logo"));
m_pNickName = static_cast<CLabelUI*>(m_PaintManager.FindControl(L"Lab_NickName"));
m_pEditNickName = static_cast<CRichEditUI*>(m_PaintManager.FindControl(L"Edit_Nickname"));
m_pBtnModifyNickName = static_cast<CButtonUI*>(m_PaintManager.FindControl(L"Btn_ModifyNick"));
m_phandImge = static_cast<CCircleImageUI*>(m_PaintManager.FindControl(L"handimg"));
m_pCourseWeb = static_cast<CCef3WebUI*>(m_PaintManager.FindControl(L"Cef3WebMyCourseList"));
SetIcon(IDI_ICON1);
SetWindowTextW(m_hWnd, App_Name);
//create new webUI
m_pCourseWeb->CreateBrowser();
m_pCourseWeb->SetCef3CallBack(this);
}
LRESULT CMainframe::OnSysCommand(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
bHandled = FALSE;
if (wParam == SC_CLOSE)
{
bHandled = TRUE;
return 0;
}
return __super::OnSysCommand(uMsg, wParam, lParam, bHandled);
}
CControlUI* CMainframe::CreateControl(LPCTSTR pstrClass)
{
if (_tcsicmp(pstrClass, _T("CircleImage")) == 0)
{
return new CCircleImageUI;
}
else if (_tcsicmp(pstrClass, _T("ImageAnimate")) == 0)
{
return new CImageAnimateUI;
}
else if (_tcsicmp(pstrClass, _T("VerticalLayoutBK")) == 0)
{
return new CVerticalLayoutBKUI;
}
else if (_tcsicmp(pstrClass, _T("DBCLabel")) == 0)
{
return new CDBClickLabelUI;
}
else if (_tcsicmp(pstrClass, _T("Cef3Web")) == 0 )
{
return new CCef3WebUI;
}
else if (_tcsicmp(pstrClass, _T("BrowserTab")) == 0)
{
return new CBrowserTabUI;
}
return __super::CreateControl(pstrClass);
}
LRESULT CMainframe::HandleCustomMessage(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
return 0;
}
void CMainframe::ShowTip(LPCWSTR lpText)
{
::MessageBox(m_hWnd, lpText, L"提示", MB_OK);
}
const bool CMainframe::Quit(const bool bLogout /*= false*/, const bool bForce /*= false*/)
{
return true;
}
DuiLib::CDuiString CMainframe::GetSkinFolder()
{
return L"skin\\";
}
DuiLib::CDuiString CMainframe::GetSkinFile()
{
return L"mainframe.xml";
}
DuiLib::UILIB_RESOURCETYPE CMainframe::GetResourceType() const
{
return UILIB_FILE;
}
//void CMainframe::CallJS(LPCWSTR strType, LPCWSTR lpJson)
//{
// CUTFString utfJson(lpJson);
// string strJson = utfJson.UTF8();
// string doc = CBase64::Encode((const unsigned char*)strJson.c_str(), strJson.length());
// CUTFString utf(doc.c_str());
//
// CString strContent;
// strContent.Format(L"comm_course_set(\"%s\",\"%s\")", strType, utf.UTF16());
// m_pCourseWeb->CallJS(strContent);
//}
void CMainframe::ShowWebLoading()
{
}
void CMainframe::OnWebLoadSucc()
{
}
void CMainframe::OnWebLoadErr()
{
}
void CMainframe::Notify(TNotifyUI& msg)
{
if (msg.sType == DUI_MSGTYPE_CLICK)
{
if (msg.pSender == m_pCloseBtn)
{
ShowWindow(false);
PostQuitMessage(0);
}
else if (msg.pSender == m_pRefreshBtn)
{
CalltestJS();
}
}
}
void CMainframe::OpenWebPage()
{
if (m_pCourseWeb)
{
//CString str = L"D:\\Users\\Tan\\source\\repos\\Rocket\\bin\\Debug\\test.html";
CString str = L" www.baidu.com";
m_pCourseWeb->OpenURL(str);
m_pCourseWeb->OpenURL(L"http://www.baidu.com");
}
}
DuiLib::CDuiString CMainframe::GetZIPFileName() const
{
return L"UISkin.zip";
}
void CMainframe::OnBrowserCreated(void* ThisUI)
{
OpenWebPage();
}
CString MakeSafeJSString(LPCWSTR szStr)
{
if (!szStr)
return L"";
CString arrSpecJSChar[9] =
{
L"\\",
L"'",
L"\"",
L"&",
L"\n",
L"\r",
L"\t",
L"\b",
L"\f",
};
CString arrSpecNewJSChar[9] =
{
L"\\\\",
L"\\'",
L"\\\"",
L"\\&",
L"\\n",
L"\\r",
L"\\t",
L"\\b",
L"\\f",
};
CString strJS = szStr;
for (int i = 0; i < 9; i++)
{
strJS.Replace(arrSpecJSChar[i], arrSpecNewJSChar[i]);
}
return strJS;
}
void CMainframe::CalltestJS()
{
if (m_pCourseWeb) {
m_pCourseWeb->CallJSCommonFunc(L"123", L"4556");
}
}
void CMainframe::OnLoadEnd(void* ThisUI)
{
}
void CMainframe::OnLoadError(int nError, void* ThisUI)
{
}
void CMainframe::OnJSCallCPlus(LPCWSTR lpwsId, LPCWSTR lpwsContent, void* ThisUI)
{
if (lstrcmpW(lpwsContent, L"enterclass") == 0)
{
ShowWindow(false);
if (proom == nullptr) {
proom = new CRoomWindow;
proom->Create(NULL, L"room", UI_WNDSTYLE_FRAME, 0L);
}
proom->ShowWindow(true);
proom->CenterWindow();
}
CString str;
str.Format(L"%s%s", L"这是测试调用 ", lpwsContent);
ShowTip(str);
if (lstrcmpW(lpwsId, L"openurl") == 0 && lstrcmpW(lpwsContent, L"") != 0)
{
//::ShellExecute(NULL, L"open", lpwsContent, NULL, NULL, SW_SHOWNORMAL);
}
}
void CMainframe::OnBrowserClosed()
{
}
void CMainframe::OnRenderProcessTerminated(LPCWSTR lpwsUrl, int nStatus)
{
//课表render进程意外中止,reload
}
void CMainframe::OnTitleChange(LPCWSTR lpTitle, void* ThisUI)
{
}
void CMainframe::OnAddressChange(LPCWSTR lpwsaddress, void* ThisUI)
{
}
void CMainframe::OnCookie(LPCWSTR cookie, void* ThisUI)
{
}
void CMainframe::OnLoadingStateChange(void* ThisUI, bool bisLoading, bool isgoback, bool isgoforure)
{
}
LRESULT CMainframe::OnSetFocus(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled)
{
return S_OK;
}
LRESULT CMainframe::OnKillFocus(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled)
{
return S_OK;
}