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
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
|
/*
* astyle --force-indent=tab=4 --brackets=linux --indent-switches
* --pad=oper --one-line=keep-blocks --unpad=paren
*
* Miranda IM: the free IM client for Microsoft* Windows*
*
* Copyright 2000-2010 Miranda ICQ/IM project,
* all portions of this codebase are copyrighted to the people
* listed in contributors.txt.
*
* 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.
*
* part of clist_ng plugin for Miranda.
*
* (C) 2005-2010 by silvercircle _at_ gmail _dot_ com and contributors
*
* $Id: utils.cpp 137 2010-10-16 21:03:23Z silvercircle $
*
* utility functions for clist_ng.
*/
#include <commonheaders.h>
#define RTF_DEFAULT_HEADER L"{\\rtf1\\ansi\\deff0\\pard\\li%u\\fi-%u\\ri%u\\tx%u"
wchar_t* WarningDlg::m_warnings[WarningDlg::WARN_LAST] = {
LPGENT("Notes|release notes"),
LPGENT("Skin loading error|The skin cannot be loaded"),
LPGENT("Overwrite skin file|You are about to save your customized settings to the \\b1 original skin file.\\b0 This could cause problems and may require to reinstall the skin.\nYou should use \\b1 Save as user modification\\b0 to keep the original skin untouched.\n\nContinue?")
};
MWindowList WarningDlg::hWindowList = 0;
/**
* ensure that a path name ends on a trailing backslash
* @param szPathname - pathname to check
*/
void Utils::ensureTralingBackslash(wchar_t *szPathname)
{
if(szPathname[lstrlenW(szPathname) - 1] != '\\')
wcscat(szPathname, L"\\");
}
void Utils::extractResource(const HMODULE h, const UINT uID, const wchar_t* tszName, const wchar_t* tszPath,
const wchar_t* tszFilename, bool fForceOverwrite)
{
HRSRC hRes;
HGLOBAL hResource;
wchar_t szFilename[MAX_PATH];
hRes = FindResourceW(h, MAKEINTRESOURCE(uID), tszName);
if(hRes) {
hResource = LoadResource(h, hRes);
if(hResource) {
HANDLE hFile;
char *pData = (char *)LockResource(hResource);
DWORD dwSize = SizeofResource(g_hInst, hRes), written = 0;
mir_sntprintf(szFilename, MAX_PATH, L"%s%s", tszPath, tszFilename);
if(!fForceOverwrite) {
if(PathFileExistsW(szFilename))
return;
}
if((hFile = CreateFileW(szFilename, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0)) != INVALID_HANDLE_VALUE) {
WriteFile(hFile, (void *)pData, dwSize, &written, NULL);
CloseHandle(hFile);
}
else {
wchar_t wszTemp[512];
mir_sntprintf(wszTemp, 512, L"%s - (WIN32 Error: %d)", szFilename, GetLastError());
throw(CRTException("Error while extracting base skin.", wszTemp));
}
}
}
}
/**
* enable or disable a dialog control
*/
void TSAPI Utils::enableDlgControl(const HWND hwnd, UINT id, BOOL fEnable)
{
::EnableWindow(::GetDlgItem(hwnd, id), fEnable);
}
/**
* show or hide a dialog control
*/
void TSAPI Utils::showDlgControl(const HWND hwnd, UINT id, int showCmd)
{
::ShowWindow(::GetDlgItem(hwnd, id), showCmd);
}
/**
* load a system library from the Windows system path and return its module
* handle.
*
* return 0 and throw an exception if something goes wrong.
*/
HMODULE Utils::loadSystemLibrary(const wchar_t* szFilename, bool useGetHandle)
{
wchar_t sysPathName[MAX_PATH + 2];
HMODULE _h = 0;
try {
if(0 == ::GetSystemDirectoryW(sysPathName, MAX_PATH))
throw(CRTException("Error while loading system library", szFilename));
sysPathName[MAX_PATH - 1] = 0;
if(wcslen(sysPathName) + wcslen(szFilename) >= MAX_PATH)
throw(CRTException("Error while loading system library", szFilename));
lstrcatW(sysPathName, szFilename);
if(useGetHandle)
_h = ::GetModuleHandle(sysPathName);
else
_h = LoadLibraryW(sysPathName);
if(0 == _h)
throw(CRTException("Error while loading system library", szFilename));
}
catch(CRTException& ex) {
ex.display();
return(0);
}
return(_h);
}
DWORD __fastcall Utils::hexStringToLong(const char *szSource)
{
char *stopped;
COLORREF clr = strtol(szSource, &stopped, 16);
if(clr == -1)
return clr;
return(RGB(GetBValue(clr), GetGValue(clr), GetRValue(clr)));
}
/**
* Case insensitive _tcsstr
*
* @param szString TCHAR *: String to be searched
* @param szSearchFor
* TCHAR *: String that should be found in szString
*
* @return TCHAR *: found position of szSearchFor in szString. 0 if szSearchFor was not found
*/
const wchar_t* Utils::striStr(const wchar_t* szString, const wchar_t* szSearchFor)
{
if(szString && *szString) {
if (0 == szSearchFor || 0 == *szSearchFor)
return(szString);
for(; *szString; ++szString) {
if(towupper(*szString) == towupper(*szSearchFor)) {
const wchar_t* h, *n;
for(h = szString, n = szSearchFor; *h && *n; ++h, ++n) {
if(towupper(*h) != towupper(*n))
break;
}
if(!*n)
return(szString);
}
}
return(0);
}
else
return(0);
}
int Utils::pathIsAbsolute(const wchar_t* path)
{
if (!path || !(lstrlenW(path) > 2))
return 0;
if ((path[1] == ':' && path[2] == '\\') || (path[0] == '\\' && path[1] == '\\'))
return 1;
return 0;
}
size_t Utils::pathToRelative(const wchar_t* pSrc, wchar_t* pOut, const wchar_t* szBase)
{
const wchar_t* tszBase = szBase ? szBase : cfg::szProfileDir;
pOut[0] = 0;
if (!pSrc || !lstrlenW(pSrc) || lstrlenW(pSrc) > MAX_PATH)
return 0;
if (!pathIsAbsolute(pSrc)) {
mir_sntprintf(pOut, MAX_PATH, L"%s", pSrc);
return lstrlenW(pOut);
} else {
wchar_t szTmp[MAX_PATH];
mir_sntprintf(szTmp, _countof(szTmp), L"%s", pSrc);
if (striStr(szTmp, tszBase)) {
if(tszBase[lstrlenW(tszBase) - 1] == '\\')
mir_sntprintf(pOut, MAX_PATH, L"%s", pSrc + lstrlenW(tszBase));
else {
mir_sntprintf(pOut, MAX_PATH, L"%s", pSrc + lstrlenW(tszBase) + 1 );
//pOut[0]='.';
}
return(lstrlenW(pOut));
} else {
mir_sntprintf(pOut, MAX_PATH, L"%s", pSrc);
return(lstrlenW(pOut));
}
}
}
/**
* Translate a relativ path to an absolute, using the current profile
* data directory.
*
* @param pSrc TCHAR *: input path + filename (relative)
* @param pOut TCHAR *: the result
* @param szBase TCHAR *: (OPTIONAL) base path for the translation. Can be 0 in which case
* the function will use m_szProfilePath (usually \tabSRMM below %miranda_userdata%
*
* @return
*/
size_t Utils::pathToAbsolute(const wchar_t* pSrc, wchar_t* pOut, const wchar_t* szBase)
{
const wchar_t* tszBase = szBase ? szBase : cfg::szProfileDir;
const wchar_t* wszFmt = (tszBase[lstrlenW(tszBase) - 1] == '\\' ? L"%s%s" : L"%s\\%s");
pOut[0] = 0;
if (!pSrc || !lstrlenW(pSrc) || lstrlenW(pSrc) > MAX_PATH)
return 0;
if (pathIsAbsolute(pSrc) && pSrc[0]!='.')
mir_sntprintf(pOut, MAX_PATH, L"%s", pSrc);
else if (pSrc[0]=='.')
mir_sntprintf(pOut, MAX_PATH, wszFmt, tszBase, pSrc + 1);
else
mir_sntprintf(pOut, MAX_PATH, wszFmt, tszBase, pSrc);
return lstrlenW(pOut);
}
/**
* extract the clicked URL from a rich edit control. Return the URL as TCHAR*
* caller MUST mir_free() the returned string
* @param hwndRich - rich edit window handle
* @return wchar_t* extracted URL
*/
const wchar_t* Utils::extractURLFromRichEdit(const ENLINK* _e, const HWND hwndRich)
{
TEXTRANGEW tr = {0};
CHARRANGE sel = {0};
::SendMessageW(hwndRich, EM_EXGETSEL, 0, (LPARAM) & sel);
if (sel.cpMin != sel.cpMax)
return(0);
tr.chrg = _e->chrg;
tr.lpstrText = (wchar_t *)mir_alloc(2 * (tr.chrg.cpMax - tr.chrg.cpMin + 8));
::SendMessageW(hwndRich, EM_GETTEXTRANGE, 0, (LPARAM) & tr);
if (wcschr(tr.lpstrText, '@') != NULL && wcschr(tr.lpstrText, ':') == NULL && wcschr(tr.lpstrText, '/') == NULL) {
::MoveMemory(tr.lpstrText + 7, tr.lpstrText, sizeof(TCHAR) * (tr.chrg.cpMax - tr.chrg.cpMin + 1));
::CopyMemory(tr.lpstrText, L"mailto:", 7);
}
return(tr.lpstrText);
}
/**
* implementation of the CWarning class
*/
WarningDlg::WarningDlg(const wchar_t *tszTitle, const wchar_t *tszText, const UINT uId, const DWORD dwFlags)
{
m_pszTitle = pSmartWstring(new std::basic_string<wchar_t>(tszTitle));
m_pszText = pSmartWstring(new std::basic_string<wchar_t>(tszText));
m_uId = uId;
m_hFontCaption = 0;
m_dwFlags = dwFlags;
m_fIsModal = ((m_dwFlags & MB_YESNO || m_dwFlags & MB_YESNOCANCEL) ? true : false);
}
WarningDlg::~WarningDlg()
{
if(m_hFontCaption)
::DeleteObject(m_hFontCaption);
#if defined(__LOGDEBUG_)
_DebugTraceW(L"destroy object");
#endif
}
LRESULT WarningDlg::ShowDialog() const
{
if(!m_fIsModal) {
::CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_WARNING), 0, stubDlgProc, reinterpret_cast<LPARAM>(this));
return(0);
}
else {
LRESULT res = ::DialogBoxParam(g_hInst, MAKEINTRESOURCE(IDD_WARNING), 0, stubDlgProc, reinterpret_cast<LPARAM>(this));
return(res);
}
}
__int64 WarningDlg::getMask()
{
__int64 mask = 0;
DWORD dwLow = cfg::getDword("CList", "cWarningsL", 0);
DWORD dwHigh = cfg::getDword("CList", "cWarningsH", 0);
mask = ((((__int64)dwHigh) << 32) & 0xffffffff00000000) | dwLow;
return(mask);
}
/**
* send cancel message to all open warning dialogs so they are destroyed
* before plugin is unloaded.
*
* called by the OkToExit handler in globals.cpp
*/
void WarningDlg::destroyAll()
{
if(hWindowList)
WindowList_Broadcast(hWindowList, WM_COMMAND, MAKEWPARAM(IDCANCEL, 0), 0);
}
/**
* show a CWarning dialog using the id value. Check whether the user has chosen to
* not show this message again. This has room for 64 different warning dialogs, which
* should be enough in the first place. Extending it should not be too hard though.
*/
LRESULT WarningDlg::show(const int uId, DWORD dwFlags, const wchar_t* tszTxt)
{
wchar_t* separator_pos = 0;
__int64 mask = 0, val = 0;
LRESULT result = 0;
wchar_t* _s = 0;
if (0 == hWindowList)
hWindowList = WindowList_Create();
/*
* don't open new warnings when shutdown was initiated (modal ones will otherwise
* block the shutdown)
*/
if(cfg::shutDown)
return(-1);
if(uId >= 0) {
mask = getMask();
val = ((__int64)1L) << uId;
}
else
mask = val = 0;
if(!(0 == (mask & val) || dwFlags & CWF_NOALLOWHIDE))
return(-1);
if(tszTxt)
_s = const_cast<wchar_t *>(tszTxt);
else {
if(uId != -1) {
if(dwFlags & CWF_UNTRANSLATED)
_s = const_cast<wchar_t *>(m_warnings[uId]);
else {
/*
* revert to untranslated warning when the translated message
* is not well-formatted.
*/
_s = const_cast<wchar_t *>(TranslateW(m_warnings[uId]));
if(wcslen(_s) < 3 || 0 == wcschr(_s, '|'))
_s = const_cast<wchar_t *>(m_warnings[uId]);
}
}
else if(-1 == uId && tszTxt) {
dwFlags |= CWF_NOALLOWHIDE;
_s = (dwFlags & CWF_UNTRANSLATED ? const_cast<wchar_t *>(tszTxt) : TranslateW(tszTxt));
}
else
return(-1);
}
if((wcslen(_s) > 3) && ((separator_pos = wcschr(_s, '|')) != 0)) {
wchar_t *s = reinterpret_cast<wchar_t *>(mir_alloc((wcslen(_s) + 1) * 2));
wcscpy(s, _s);
separator_pos = wcschr(s, '|');
if(separator_pos) {
separator_pos[0] = 0;
WarningDlg *w = new WarningDlg(s, &separator_pos[1], uId, dwFlags);
if(!(dwFlags & MB_YESNO || dwFlags & MB_YESNOCANCEL)) {
w->ShowDialog();
mir_free(s);
}
else {
result = w->ShowDialog();
mir_free(s);
return(result);
}
}
else
mir_free(s);
}
return(-1);
}
/**
* stub dlg procedure. Just register the object pointer in WM_INITDIALOG
*/
INT_PTR CALLBACK WarningDlg::stubDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
WarningDlg *w = reinterpret_cast<WarningDlg *>(::GetWindowLongPtr(hwnd, GWLP_USERDATA));
if(w)
return(w->dlgProc(hwnd, msg, wParam, lParam));
switch(msg) {
case WM_INITDIALOG: {
w = reinterpret_cast<WarningDlg *>(lParam);
if(w) {
::SetWindowLongPtr(hwnd, GWLP_USERDATA, lParam);
return(w->dlgProc(hwnd, msg, wParam, lParam));
}
break;
}
#if defined(__LOGDEBUG_)
case WM_NCDESTROY:
_DebugTraceW(L"window destroyed");
break;
#endif
default:
break;
}
return(FALSE);
}
/**
* dialog procedure for the warning dialog box
*/
INT_PTR CALLBACK WarningDlg::dlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg) {
case WM_INITDIALOG: {
HICON hIcon = 0;
UINT uResId = 0;
TCHAR temp[1024];
SETTEXTEX stx = {ST_SELECTION, CP_UTF8};
size_t pos = 0;
m_hwnd = hwnd;
::SetWindowTextW(hwnd, L"Clist NG warning");
::SendMessage(hwnd, WM_SETICON, ICON_BIG, reinterpret_cast<LPARAM>(Skin_LoadIcon(SKINICON_OTHER_MIRANDA, true)));
::SendMessage(hwnd, WM_SETICON, ICON_SMALL, reinterpret_cast<LPARAM>(Skin_LoadIcon(SKINICON_OTHER_MIRANDA)));
::SendDlgItemMessage(hwnd, IDC_WARNTEXT, EM_AUTOURLDETECT, (WPARAM) TRUE, 0);
::SendDlgItemMessage(hwnd, IDC_WARNTEXT, EM_SETEVENTMASK, 0, ENM_LINK);
mir_sntprintf(temp, 1024, RTF_DEFAULT_HEADER, 0, 0, 0, 30*15);
std::basic_string<wchar_t> *str = new std::basic_string<wchar_t>(temp);
str->append((*m_pszText).c_str());
str->append(L"}");
TranslateDialogDefault(hwnd);
/*
* convert normal line breaks to rtf
*/
while((pos = str->find(L"\n")) != str->npos) {
str->erase(pos, 1);
str->insert(pos, L"\\line ");
}
char *utf8 = Utf8EncodeW(str->c_str());
::SendDlgItemMessage(hwnd, IDC_WARNTEXT, EM_SETTEXTEX, (WPARAM)&stx, (LPARAM)utf8);
mir_free(utf8);
delete str;
::SetDlgItemTextW(hwnd, IDC_CAPTION, (*m_pszTitle).c_str());
if(m_dwFlags & CWF_NOALLOWHIDE)
Utils::showDlgControl(hwnd, IDC_DONTSHOWAGAIN, SW_HIDE);
if(m_dwFlags & MB_YESNO || m_dwFlags & MB_YESNOCANCEL) {
Utils::showDlgControl(hwnd, IDOK, SW_HIDE);
::SetFocus(::GetDlgItem(hwnd, IDCANCEL));
}
else {
Utils::showDlgControl(hwnd, IDCANCEL, SW_HIDE);
Utils::showDlgControl(hwnd, IDYES, SW_HIDE);
Utils::showDlgControl(hwnd, IDNO, SW_HIDE);
::SetFocus(::GetDlgItem(hwnd, IDOK));
}
if(m_dwFlags & MB_ICONERROR || m_dwFlags & MB_ICONHAND)
uResId = 32513;
else if(m_dwFlags & MB_ICONEXCLAMATION || m_dwFlags & MB_ICONWARNING)
uResId = 32515;
else if(m_dwFlags & MB_ICONASTERISK || m_dwFlags & MB_ICONINFORMATION)
uResId = 32516;
else if(m_dwFlags & MB_ICONQUESTION)
uResId = 32514;
if(uResId)
hIcon = reinterpret_cast<HICON>(::LoadImage(0, MAKEINTRESOURCE(uResId), IMAGE_ICON, 0, 0, LR_SHARED | LR_DEFAULTSIZE));
else
hIcon = Skin_LoadIcon(SKINICON_EVENT_MESSAGE, true);
::SendDlgItemMessageW(hwnd, IDC_WARNICON, STM_SETICON, reinterpret_cast<WPARAM>(hIcon), 0);
if(!(m_dwFlags & MB_YESNO || m_dwFlags & MB_YESNOCANCEL))
::ShowWindow(hwnd, SW_SHOWNORMAL);
WindowList_Add(hWindowList, hwnd, (MCONTACT)hwnd);
return(TRUE);
}
case WM_CTLCOLORSTATIC: {
HWND hwndChild = reinterpret_cast<HWND>(lParam);
UINT id = ::GetDlgCtrlID(hwndChild);
if(0 == m_hFontCaption) {
HFONT hFont = reinterpret_cast<HFONT>(::SendDlgItemMessage(hwnd, IDC_CAPTION, WM_GETFONT, 0, 0));
LOGFONT lf = {0};
::GetObject(hFont, sizeof(lf), &lf);
lf.lfHeight = (int)((double)lf.lfHeight * 1.7f);
m_hFontCaption = ::CreateFontIndirect(&lf);
::SendDlgItemMessage(hwnd, IDC_CAPTION, WM_SETFONT, (WPARAM)m_hFontCaption, FALSE);
}
if(IDC_CAPTION == id) {
::SetTextColor(reinterpret_cast<HDC>(wParam), ::GetSysColor(COLOR_HIGHLIGHT));
::SendMessage(hwndChild, WM_SETFONT, (WPARAM)m_hFontCaption, FALSE);
}
if(IDC_WARNGROUP != id && IDC_DONTSHOWAGAIN != id) {
::SetBkColor((HDC)wParam, ::GetSysColor(COLOR_WINDOW));
return reinterpret_cast<INT_PTR>(::GetSysColorBrush(COLOR_WINDOW));
}
break;
}
case WM_COMMAND:
switch(LOWORD(wParam)) {
case IDOK:
case IDCANCEL:
case IDYES:
case IDNO:
if(!m_fIsModal && (IDOK == LOWORD(wParam) || IDCANCEL == LOWORD(wParam))) { // modeless dialogs can receive a IDCANCEL from destroyAll()
::SetWindowLongPtr(hwnd, GWLP_USERDATA, 0);
delete this;
WindowList_Remove(hWindowList, hwnd);
::DestroyWindow(hwnd);
}
else {
::SetWindowLongPtr(hwnd, GWLP_USERDATA, 0);
delete this;
WindowList_Remove(hWindowList, hwnd);
::EndDialog(hwnd, LOWORD(wParam));
}
break;
case IDC_DONTSHOWAGAIN: {
__int64 mask = getMask(), val64 = ((__int64)1L << m_uId), newVal = 0;
newVal = mask | val64;
if(::IsDlgButtonChecked(hwnd, IDC_DONTSHOWAGAIN)) {
DWORD val = (DWORD)(newVal & 0x00000000ffffffff);
cfg::writeDword("CList", "cWarningsL", val);
val = (DWORD)((newVal >> 32) & 0x00000000ffffffff);
cfg::writeDword("CList", "cWarningsH", val);
}
break;
}
default:
break;
}
break;
case WM_NOTIFY: {
switch (((NMHDR *) lParam)->code) {
case EN_LINK:
switch (((ENLINK *) lParam)->msg) {
case WM_LBUTTONUP: {
ENLINK* e = reinterpret_cast<ENLINK *>(lParam);
const wchar_t* wszUrl = Utils::extractURLFromRichEdit(e, ::GetDlgItem(hwnd, IDC_WARNTEXT));
if(wszUrl) {
char* szUrl = mir_t2a(wszUrl);
Utils_OpenUrl(szUrl);
mir_free(szUrl);
mir_free(const_cast<TCHAR *>(wszUrl));
}
break;
}
}
break;
default:
break;
}
break;
}
default:
break;
}
return(FALSE);
}
|