-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuistatusbar.cpp
More file actions
271 lines (247 loc) · 8.17 KB
/
Copy pathuistatusbar.cpp
File metadata and controls
271 lines (247 loc) · 8.17 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
#include "stdafx.h"
namespace local {
UIStatusBar::UIStatusBar(const UIType& uitype, const bool& init_show) : UIBase(uitype, init_show) {
Init();
}
UIStatusBar::~UIStatusBar() {
UnInit();
}
void UIStatusBar::Init() {
}
void UIStatusBar::UnInit() {
}
void UIStatusBar::OnFinalMessage(HWND hWnd) {
/*delete this;*////Release can cause a crash
}
const HWND& UIStatusBar::Hwnd() const {
return UIBase::m_hWnd;
}
bool UIStatusBar::IsOpen() const {
return m_IsOpen.load();
}
void UIStatusBar::Create() {
do {
if (m_IsOpen.load())
break;
CPaintManagerUI::SetInstance(__gpHinstance);
#if 0
#ifdef _DEBUG
/*auto sss = CPaintManagerUI::GetInstancePath();*/
CPaintManagerUI::SetResourcePath(LR"(D:\__SVN__\Memade\projects\pcdown\res\skin\)");
#else
//std::string res = shared::Win::File::Read(R"(D:\__SVN__\Memade\projects\pcdown\res\skin.zip)");
////*Global::SetupGet() << shared::Win::File::Read(R"(E:\__SVN__\Memade\projects\downtool\res\setup.xml)");
//if (res.empty())
// break;
std::string res = std::string((char*)&skin_zip_res[0], sizeof(skin_zip_res));
res = shared::Encryption::WemadeDecode(res);
if (!shared::Zip::IsZipCompress(res))
break;
CPaintManagerUI::SetResourceZip(res.data(), static_cast<unsigned int>(res.size()));
#endif
#else
CPaintManagerUI::SetResourcePath(Global::PCHackerGet()->UISkinDirectory().c_str());
#endif
DWORD dwCreateStyle = UI_WNDSTYLE_FRAME;
do {
if (m_Show.load())
break;
if (!(dwCreateStyle & WS_VISIBLE))
break;
dwCreateStyle &= ~WS_VISIBLE;
} while (0);
UIBase::m_hWnd = UIFrame::Create(NULL, _TEXT("PCDown Statusbar®"), dwCreateStyle, 0L);
if (!UIBase::m_hWnd)
break;
m_IsOpen.store(true);
CenterWindow();
CPaintManagerUI::MessageLoop();
} while (0);
}
void UIStatusBar::Destory() {
do {
if (!m_IsOpen.load())
break;
for (auto& it : m_Threads)
it.join();
m_Threads.clear();
UIFrame::Close(IDOK);
m_IsOpen.store(false);
} while (0);
}
void UIStatusBar::InitWindow() {
m_pUIButtonActivateDownTable = GetCtrl<CButtonUI>(L"32986A9F93F0");
m_pUIButtonDownTotalCount = GetCtrl<CButtonUI>(L"FE58908224CC");
m_pUIProgress = GetCtrl<CProgressUI>(L"D73AF13A8F49");
m_pUITextGameDownload = GetCtrl<CLabelUI>(L"7C9745D4E9BD");
if (m_pUIButtonDownTotalCount) {
m_pUIButtonDownTotalCount->SetVisible(false);
}
if (m_pUIProgress) {
m_pUIProgress->SetValue(0);
m_pUIProgress->SetVisible(false);
}
if (m_pUITextGameDownload)
m_pUITextGameDownload->SetVisible(false);
}
LRESULT UIStatusBar::OnKeyDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) {
bHandled = FALSE;
return 0;
}
LRESULT UIStatusBar::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) {
LONG styleValue = ::GetWindowLongW(*this, GWL_STYLE);
styleValue &= ~WS_CAPTION;
::SetWindowLongW(*this, GWL_STYLE, styleValue | WS_CLIPSIBLINGS | WS_CLIPCHILDREN);
LONG ExStyleValue = ::GetWindowLongW(*this, GWL_EXSTYLE);
ExStyleValue |= WS_EX_TOOLWINDOW;
::SetWindowLongW(*this, GWL_EXSTYLE, ExStyleValue);
m_pm.Init(GetHWND());
CDialogBuilder builder;
CControlUI* pRoot = builder.Create(std::wstring(GetWindowClassName()).append(_TEXT(".xml")).c_str(), (LPCTSTR)0, NULL, &m_pm);
ASSERT(pRoot && "Failed to parse 'ui.xml'");
m_pm.AttachDialog(pRoot);
m_pm.AddNotifier(this);
bHandled = TRUE;
return 0;
}
LRESULT UIStatusBar::OnGetMinMaxInfo(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) {
bHandled = FALSE;
return 0;
}
LRESULT UIStatusBar::OnSysCommand(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) {
bHandled = FALSE;
return 0;
}
LRESULT UIStatusBar::HandleCustomMessage(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) {
bHandled = FALSE;
return 0;
}
LRESULT UIStatusBar::OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) {
::PostQuitMessage(0L);
bHandled = TRUE;
return 0;
}
LRESULT UIStatusBar::OnChar(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) {
bHandled = FALSE;
return 0;
}
CControlUI* UIStatusBar::CreateControl(LPCTSTR pstrClassName) {
return nullptr;
}
void UIStatusBar::Notify(TNotifyUI& msg) {
if (msg.sType == DUI_MSGTYPE_HEADERCLICK) {
}///DUI_MSGTYPE_HEADERCLICK
#if 0
else if (msg.sType == DUI_MSGTYPE_LINK) {
CTextUI* pText = (CTextUI*)msg.pSender;
CDuiString* strUrl = pText->GetLinkContent(0);
::ShellExecute(NULL, _T("open"), strUrl->GetData(), NULL, NULL, SW_SHOWNORMAL);
}
#endif
else if (msg.sType == DUI_MSGTYPE_CHECKCLICK) {
}
else if (msg.sType == DUI_MSGTYPE_CLICK) {
if (m_pUIButtonActivateDownTable == msg.pSender) {//!@ 激活下载管理窗口按钮
do {
HWND hParent = Global::PCHackerGet()->ParentHwnd(EnUIType::DownManagerUI);
HWND hPCHacher = \
reinterpret_cast<HWND>(Global::PCHackerGet()->UIGetHwnd(EnUIType::DownManagerUI));
if (!hPCHacher) {
if (!Global::PCHackerGet()->UICreate(EnUIType::DownManagerUI, false))
break;
hPCHacher = \
reinterpret_cast<HWND>(Global::PCHackerGet()->UIGetHwnd(EnUIType::DownManagerUI));
if (!hPCHacher)
break;
if (hParent)
::SetParent(hPCHacher, hParent);
}
if (Global::PCHackerGet()->UIShowIs(EnUIType::DownManagerUI)) {
Global::PCHackerGet()->UIShow(EnUIType::DownManagerUI, false);
}
else {
RECT rtStatusbarClient = { 0 };
RECT rtStatusbarWindow = { 0 };
::GetClientRect(UIBase::m_hWnd, &rtStatusbarClient);
::GetWindowRect(UIBase::m_hWnd, &rtStatusbarWindow);
//!@ 如果指定了模块父窗口则启用客户端定位否则启用屏幕窗口定位
if (hParent) {
RECT rtPCDownClient = { 0 };
::GetClientRect(hPCHacher, &rtPCDownClient);
RECT rtParentClient = { 0 };
::GetClientRect(hParent, &rtParentClient);
::SetWindowPos(hPCHacher, NULL,
rtStatusbarClient.left,
rtParentClient.bottom - (rtPCDownClient.bottom - rtPCDownClient.top) - (rtStatusbarClient.bottom - rtStatusbarClient.top),
0, 0, SWP_NOSIZE | SWP_NOZORDER);
}
else {
RECT rtPCDownWindow = { 0 };
::GetWindowRect(hPCHacher, &rtPCDownWindow);
::SetWindowPos(hPCHacher, NULL,
rtStatusbarWindow.left,
rtStatusbarWindow.top - (rtPCDownWindow.bottom - rtPCDownWindow.top),
0, 0, SWP_NOSIZE | SWP_NOZORDER);
}
Global::PCHackerGet()->UIShow(EnUIType::DownManagerUI, true);
}
} while (0);
}
}
else {
}
}
void UIStatusBar::DownStatusTotalCount(const size_t& total) {
std::lock_guard<std::mutex> lock{ *m_Mutex };
do {
if (!m_pUIButtonDownTotalCount)
break;
auto text = m_pUIButtonDownTotalCount->GetText();
size_t current = ::_wtol(text.GetData());
if (current == total)
break;
m_pUIButtonDownTotalCount->SetText(std::to_wstring(total).c_str());
} while (0);
}
size_t UIStatusBar::DownStatusTotoalCount() const {
size_t result = 0;
std::lock_guard<std::mutex> lock{ *m_Mutex };
do {
if (!m_pUIButtonDownTotalCount)
break;
auto text = m_pUIButtonDownTotalCount->GetText();
result = ::_wtol(text.GetData());
} while (0);
return result;
}
void UIStatusBar::StatusbarProgressCtrl(const bool& show) {
std::lock_guard<std::mutex> lock{ *m_Mutex };
if (m_pUIButtonDownTotalCount)
m_pUIButtonDownTotalCount->SetVisible(show);
if (m_pUIProgress)
m_pUIProgress->SetVisible(show);
if (m_pUITextGameDownload)
m_pUITextGameDownload->SetVisible(show);
}
void UIStatusBar::Refresh() const {
std::lock_guard<std::mutex> lock{ *m_Mutex };
do {
HWND hParent = ::GetParent(UIBase::m_hWnd);
if (!hParent)
break;
if (m_tagSize.cx <= 0 && m_tagSize.cy <= 0)
break;
RECT rtParentWindow = { 0 };
::GetWindowRect(hParent, &rtParentWindow);
RECT rtParentClient = { 0 };
::GetWindowRect(hParent, &rtParentClient);
int cx = rtParentClient.right - rtParentClient.left;
int cy = rtParentClient.bottom - rtParentClient.top;
int x = m_tagPoint.x;
int y = cy - m_tagSize.cy + m_tagPoint.y;
cx = m_tagSize.cx <= 0 ? cx : m_tagSize.cx;
cy = m_tagSize.cy <= 0 ? cy : m_tagSize.cy;
::SetWindowPos(UIBase::m_hWnd, NULL, x, y, cx, cy, SWP_NOACTIVATE);
} while (0);
}
}///namespace local