-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuimessagebox.cpp
More file actions
228 lines (189 loc) · 5.99 KB
/
uimessagebox.cpp
File metadata and controls
228 lines (189 loc) · 5.99 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
#include "stdafx.h"
namespace local {
UIMessageBox::UIMessageBox(const UIType& uitype, const bool& init_show) : UIBase(uitype, init_show) {
Init();
}
UIMessageBox::~UIMessageBox() {
UnInit();
}
void UIMessageBox::Init() {
}
void UIMessageBox::UnInit() {
}
void UIMessageBox::OnFinalMessage(HWND hWnd) {
/*delete this;*////Release can cause a crash
}
const HWND& UIMessageBox::Hwnd() const {
return UIBase::m_hWnd;
}
bool UIMessageBox::IsOpen() const {
return m_IsOpen.load();
}
void UIMessageBox::Create() {
do {
if (m_IsOpen.load())
break;
CPaintManagerUI::SetInstance(__gpHinstance);
#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
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 Configure®"), dwCreateStyle, 0L);
if (!UIBase::m_hWnd)
break;
m_IsOpen.store(true);
CenterWindow();
CPaintManagerUI::MessageLoop();
} while (0);
}
void UIMessageBox::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 UIMessageBox::InitWindow() {
#if 0
m_Threads.emplace_back(
[&]() {
bool success = false;
do {
const auto& objects = Global::SetupGet()->Objects();
do {//!@ 初始化主推软件信息
auto pSoftName = GetCtrl<CLabelUI>(_T("5350E081"));
if (pSoftName)
pSoftName->SetText(shared::IConv::MBytesToWString(Global::SetupGet()->RecommendGet().Name).c_str());
auto pSoftSize = GetCtrl<CLabelUI>(_T("E29020F5"));
if (pSoftSize) {
auto text = pSoftSize->GetText();
pSoftSize->SetText(
std::format(text.GetData(), shared::IConv::MBytesToWString(Global::SetupGet()->RecommendGet().Size)).c_str());
}
auto pSoftDownCount = GetCtrl<CLabelUI>(_T("4FB1106F"));
if (pSoftDownCount) {
std::uint64_t seed = time(0);
seed = seed * 214013L + 2531011L;
int nDownCount = 30000 + ((seed >> 16) % 99999);
auto text = pSoftDownCount->GetText();
pSoftDownCount->SetText(
std::format(text.GetData(), std::to_wstring(nDownCount)).c_str());
}
} while (0);
//!@ 初始化资源列表
do {
if (objects.empty())
break;
auto pResList = GetCtrl<CListUI>(_T("FD334C31"));
if (!pResList)
break;
CDialogBuilder builder;
for (const auto& object : objects) {
do {
auto pNote = builder.Create<CContainerUI>(_T("object.xml"));
if (!pNote)
break;
auto name = pNote->GetSubCtrl<CLabelUI>(_T("30A91164"));
if (name)
name->SetText(shared::IConv::MBytesToWString(object.second.china).c_str());
pResList->Add(pNote);
} while (0);
}
success = true;
} while (0);
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
if (!m_IsOpen.load() || success)
break;
} while (1);
});
#endif
}
LRESULT UIMessageBox::OnKeyDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) {
bHandled = FALSE;
return 0;
}
LRESULT UIMessageBox::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 UIMessageBox::OnGetMinMaxInfo(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) {
bHandled = FALSE;
return 0;
}
LRESULT UIMessageBox::OnSysCommand(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) {
bHandled = FALSE;
return 0;
}
LRESULT UIMessageBox::HandleCustomMessage(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) {
bHandled = FALSE;
return 0;
}
LRESULT UIMessageBox::OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) {
::PostQuitMessage(0L);
bHandled = TRUE;
return 0;
}
LRESULT UIMessageBox::OnChar(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) {
bHandled = FALSE;
return 0;
}
CControlUI* UIMessageBox::CreateControl(LPCTSTR pstrClassName) {
return nullptr;
}
void UIMessageBox::Notify(TNotifyUI& msg) {
if (msg.sType == DUI_MSGTYPE_HEADERCLICK) {
}///DUI_MSGTYPE_HEADERCLICK
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);
}
else if (msg.sType == DUI_MSGTYPE_CHECKCLICK) {
}
else if (msg.sType == DUI_MSGTYPE_CLICK) {
const auto name = msg.pSender->GetName();
if (!name.Compare(_T("0B3A1B17"))) {
OnShowMininized();
}
else if (!name.Compare(_T("A3B405BB"))) {
UIMessageBox::Close();
}
}
else {
}
}
}///namespace local