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
|
/*
UserinfoEx plugin for Miranda IM
Copyright:
© 2006-2010 DeathAxe, Yasnovidyashii, Merlin, K. Romanov, Kreol
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "../stdafx.h"
/***********************************************************************************************************
* windows procedure
***********************************************************************************************************/
/**
* name: DlgProcProgress
* desc: dialog procedure for the progress dialog
* params: none
* return: nothing
**/
INT_PTR CALLBACK DlgProcProgress(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg)
{
case WM_INITDIALOG:
{
const ICONCTRL idIcon[] = {
{ IDI_IMPORT, WM_SETICON, NULL },
{ IDI_IMPORT, STM_SETIMAGE, ICO_DLGLOGO },
{ IDI_BTN_CLOSE, BM_SETIMAGE, IDCANCEL }
};
const int numIconsToSet = g_plugin.getByte(SET_ICONS_BUTTONS, 1) ? _countof(idIcon) : 2;
IcoLib_SetCtrlIcons(hDlg, idIcon, numIconsToSet);
TranslateDialogDefault(hDlg);
SendDlgItemMessage(hDlg, IDCANCEL, BUTTONTRANSLATE, NULL, NULL);
SendDlgItemMessage(hDlg, IDC_PROGRESS, PBM_SETPOS, 0, 0);
SendDlgItemMessage(hDlg, IDC_PROGRESS2, PBM_SETPOS, 0, 0);
SetWindowLongPtr(hDlg, GWLP_USERDATA, 0);
UpdateWindow(hDlg);
break;
}
case WM_CTLCOLORSTATIC:
switch (GetWindowLongPtr((HWND)lParam, GWLP_ID)) {
case STATIC_WHITERECT:
case TXT_SETTING:
case IDC_PROGRESS:
case TXT_CONTACT:
case IDC_PROGRESS2:
SetBkColor((HDC)wParam, RGB(255, 255, 255));
return (INT_PTR)GetStockObject(WHITE_BRUSH);
}
return FALSE;
case WM_COMMAND:
if (HIWORD(wParam) == BN_CLICKED) {
switch (LOWORD(wParam)) {
case IDCANCEL:
// in the progress dialog, use the user data to indicate that the user has pressed cancel
ShowWindow(hDlg, SW_HIDE);
SetWindowLongPtr(hDlg, GWLP_USERDATA, 1);
return TRUE;
}
}
break;
}
return FALSE;
}
/**
* name: CProgress
* class: CProgress
* desc: create the progress dialog and return a handle as pointer to the datastructure
* params: none
* return: nothing
**/
CProgress::CProgress()
{
_dwStartTime = GetTickCount();
_hDlg = CreateDialog(g_plugin.getInst(), MAKEINTRESOURCE(IDD_COPYPROGRESS), nullptr, DlgProcProgress);
}
/**
* name: ~CProgress
* class: CProgress
* desc: destroy the progress dialog and its data structure
* params: none
* return: nothing
**/
CProgress::~CProgress()
{
if (IsWindow(_hDlg)) DestroyWindow(_hDlg);
}
/**
* name: SetContactCount
* class: CProgress
* desc: number of contacts to show 100% for
* params: numContacts - the number of contacts
* return: nothing
**/
void CProgress::SetContactCount(DWORD numContacts)
{
if (_hDlg) {
HWND hProgress = GetDlgItem(_hDlg, IDC_PROGRESS2);
SendMessage(hProgress, PBM_SETRANGE32, 0, numContacts);
SendMessage(hProgress, PBM_SETPOS, 0, 0);
}
}
/**
* name: SetSettingsCount
* class: CProgress
* desc: number of settings & events to show 100% for
* params: numSettings - the number of settings & events
* return: nothing
**/
void CProgress::SetSettingsCount(DWORD numSettings)
{
if (_hDlg) {
HWND hProgress = GetDlgItem(_hDlg, IDC_PROGRESS);
SendMessage(hProgress, PBM_SETRANGE32, 0, numSettings);
SendMessage(hProgress, PBM_SETPOS, 0, 0);
}
}
/**
* name: Hide
* class: CProgress
* desc: hides the dialog
* params: none
* return: nothing
**/
void CProgress::Hide()
{
ShowWindow(_hDlg, SW_HIDE);
}
/**
* name: Update
* class: CProgress
* desc: update the progress dialog
* params: nothing
* return: FALSE if user pressed cancel, TRUE otherwise
**/
BYTE CProgress::Update()
{
MSG msg;
// show dialog after one second
if (GetTickCount() > _dwStartTime + 1000) {
ShowWindow(_hDlg, SW_SHOW);
}
UpdateWindow(_hDlg);
while (PeekMessage(&msg, _hDlg, 0, 0, PM_REMOVE) != 0) {
if (_hDlg == nullptr || !IsDialogMessage(_hDlg, &msg)) { /* Wine fix. */
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return GetWindowLongPtr(_hDlg, GWLP_USERDATA) == 0;
}
/**
* name: UpdateContact
* class: CProgress
* desc: increase contact's progressbar by one and set new text
* params: pszFormat - the text to display for the contact
* return: FALSE if user pressed cancel, TRUE otherwise
**/
BYTE CProgress::UpdateContact(LPCTSTR pszFormat, ...)
{
if (_hDlg != nullptr) {
HWND hProg = GetDlgItem(_hDlg, IDC_PROGRESS2);
if (pszFormat) {
wchar_t buf[MAX_PATH];
va_list vl;
va_start(vl, pszFormat);
mir_vsnwprintf(buf, _countof(buf), TranslateW(pszFormat), vl);
va_end(vl);
SetDlgItemText(_hDlg, TXT_CONTACT, buf);
}
SendMessage(hProg, PBM_SETPOS, (int)SendMessage(hProg, PBM_GETPOS, 0, 0) + 1, 0);
return Update();
}
return TRUE;
}
/**
* name: UpdateContact
* class: CProgress
* desc: increase setting's progressbar by one and set new text
* params: pszFormat - the text to display for the setting
* return: FALSE if user pressed cancel, TRUE otherwise
**/
BYTE CProgress::UpdateSetting(LPCTSTR pszFormat, ...)
{
if (_hDlg != nullptr) {
HWND hProg = GetDlgItem(_hDlg, IDC_PROGRESS);
if (pszFormat) {
wchar_t buf[MAX_PATH];
wchar_t tmp[MAX_PATH];
va_list vl;
va_start(vl, pszFormat);
mir_vsnwprintf(buf, _countof(buf), TranslateW(pszFormat), vl);
va_end(vl);
GetDlgItemText(_hDlg, TXT_SETTING, tmp, _countof(tmp));
if (mir_wstrcmpi(tmp,buf))
SetDlgItemText(_hDlg, TXT_SETTING, buf);
}
SendMessage(hProg, PBM_SETPOS, (int)SendMessage(hProg, PBM_GETPOS, 0, 0) + 1, 0);
return Update();
}
return TRUE;
}
|