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
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
|
// TooltipNotify.cpp: implementation of the CTooltipNotify class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
enum
{
ProtoIntBit = 0x01,
ProtoUserBit = 0x02
};
static const char* SND_ONLINE = "ttntfOnline";
static const char* SND_OFFLINE = "ttntfOffline";
static const char* SND_OTHER = "ttntfOther";
static const char* SND_TYPING = "ttntfTyping";
static const char* CONTACT_IGNORE_TTNOTIFY = "Ignore";
static const int ID_TTNTF_STATUS_TYPING = ID_STATUS_INVISIBLE + 10;
static const int ID_TTNTF_STATUS_IDLE = ID_STATUS_INVISIBLE + 11;
static const int ID_TTNTF_STATUS_NOT_IDLE = ID_STATUS_INVISIBLE + 12;
#define FONTSERV_GROUP LPGENT("Tooltip Notify")
#define FONTSERV_ONLINE LPGENT("Online")
#define FONTSERV_OFFLINE LPGENT("Offline")
#define FONTSERV_OTHER LPGENT("Other status")
#define FONTSERV_TYPING LPGENT("Typing")
#define FONTSERV_IDLE LPGENT("Idle")
struct FontEntry
{
int status;
TCHAR* name;
char* fontPrefix;
char* clrPrefix;
};
static FontEntry s_fontTable[] =
{
ID_STATUS_ONLINE, FONTSERV_ONLINE, "OnlineFont", "OnlineBgColor",
ID_STATUS_OFFLINE, FONTSERV_OFFLINE, "OfflineFont", "OfflineBgColor",
ID_TTNTF_STATUS_TYPING, FONTSERV_TYPING, "TypingFont", "TypingBgColor",
ID_TTNTF_STATUS_IDLE, FONTSERV_IDLE, "IdleFont", "IdleBgColor",
ID_TTNTF_STATUS_NOT_IDLE, FONTSERV_IDLE, "IdleFont", "IdleBgColor",
0, FONTSERV_OTHER, "OtherFont", "OtherBgColor",
};
CTooltipNotify *CTooltipNotify::s_pInstance = 0;
const char *CTooltipNotify::s_szModuleNameOld = "ttntfmod";
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CTooltipNotify::CTooltipNotify() :
m_bNt50(IsNt50())
{
if (s_pInstance != 0)
throw EAlreadyExists();
s_pInstance = this;
CTooltip::Initialize();
}
CTooltipNotify::~CTooltipNotify()
{
EndNotifyAll();
CTooltip::Deinitialize();
s_pInstance = 0;
}
void CTooltipNotify::RegisterFonts()
{
FontIDT fontId = { sizeof(fontId) };
_tcsncpy(fontId.group, FONTSERV_GROUP, _countof(fontId.group) - 1);
strncpy(fontId.dbSettingsGroup, MODULENAME, _countof(fontId.dbSettingsGroup) - 1);
fontId.flags = FIDF_DEFAULTVALID;
fontId.deffontsettings.colour = DEF_SETTING_TXTCOLOR;
fontId.deffontsettings.size = -MulDiv(DEF_SETTING_FONT_SIZE, DEF_LOGPIXELSY, 72);
fontId.deffontsettings.style = DEF_SETTING_FONT_STYLE;
fontId.deffontsettings.charset = DEF_SETTING_FONT_CHARSET;
_tcsncpy(fontId.deffontsettings.szFace, DEF_SETTING_FONT_FACE, _countof(fontId.deffontsettings.szFace) - 1);
fontId.order = 0;
_tcsncpy(fontId.backgroundGroup, FONTSERV_GROUP, _countof(fontId.backgroundGroup) - 1);
ColourIDT colorId = { sizeof(colorId) };
_tcsncpy(colorId.group, FONTSERV_GROUP, _countof(colorId.group) - 1);
strncpy(colorId.dbSettingsGroup, MODULENAME, _countof(colorId.dbSettingsGroup) - 1);
colorId.flags = 0;
colorId.defcolour = DEF_SETTING_BGCOLOR;
colorId.order = 0;
for (int i = 0; i < _countof(s_fontTable); i++) {
_tcsncpy(fontId.name, s_fontTable[i].name, _countof(fontId.name) - 1);
strncpy(fontId.prefix, s_fontTable[i].fontPrefix, _countof(fontId.prefix) - 1);
_tcsncpy(fontId.backgroundName, s_fontTable[i].name, _countof(fontId.backgroundName) - 1);
::FontRegisterT(&fontId);
_tcsncpy(colorId.name, s_fontTable[i].name, _countof(colorId.name) - 1);
strncpy(colorId.setting, s_fontTable[i].clrPrefix, _countof(colorId.setting) - 1);
::ColourRegisterT(&colorId);
}
}
void CTooltipNotify::GetFont(int iStatus, LOGFONT* lf, COLORREF* text, COLORREF* bg)
{
TCHAR* fontName = 0;
for (int i = 0; i < _countof(s_fontTable); i++) {
if (s_fontTable[i].status == iStatus) {
fontName = s_fontTable[i].name;
}
}
if (fontName == 0) {
fontName = s_fontTable[_countof(s_fontTable) - 1].name;
}
// name and group only
FontIDT fontId = { sizeof(fontId), FONTSERV_GROUP, 0 };
_tcsncpy(fontId.name, fontName, _countof(fontId.name) - 1);
*text = (COLORREF)::CallService(MS_FONT_GETT, (WPARAM)&fontId, (LPARAM)lf);
ColourIDT colorId = { sizeof(colorId), FONTSERV_GROUP, 0 };
_tcsncpy(colorId.name, fontName, _countof(colorId.name) - 1);
*bg = (COLORREF)::CallService(MS_COLOUR_GETT, (WPARAM)&colorId, 0);
}
int CTooltipNotify::ModulesLoaded(WPARAM, LPARAM)
{
MigrateSettings();
LoadSettings();
ValidateSettings();
if (m_sOptions.bFirstRun) {
db_set_b(NULL, "SkinSoundsOff", SND_ONLINE, 1);
db_set_b(NULL, "SkinSoundsOff", SND_OFFLINE, 1);
db_set_b(NULL, "SkinSoundsOff", SND_OTHER, 1);
db_set_b(NULL, "SkinSoundsOff", SND_TYPING, 1);
db_set_b(NULL, MODULENAME, "firstrun", 0);
}
SkinAddNewSoundEx(SND_ONLINE, LPGEN("Tooltip Notify"), LPGEN("Online"), "online.wav");
SkinAddNewSoundEx(SND_OFFLINE, LPGEN("Tooltip Notify"), LPGEN("Offline"), "offline.wav");
SkinAddNewSoundEx(SND_OTHER, LPGEN("Tooltip Notify"), LPGEN("Other"), "other.wav");
SkinAddNewSoundEx(SND_TYPING, LPGEN("Tooltip Notify"), LPGEN("Typing"), "typing.wav");
// register fonts
RegisterFonts();
return 0;
}
int CTooltipNotify::ProtoContactIsTyping(WPARAM hContact, LPARAM lParam)
{
if (!m_sOptions.bTyping) return 0;
if (lParam > 0) {
STooltipData *pTooltipData = new STooltipData;
pTooltipData->uiTimeout = lParam * 1000;
pTooltipData->hContact = hContact;
pTooltipData->iStatus = ID_TTNTF_STATUS_TYPING;
EndNotifyAll();
SkinPlaySound(SND_TYPING);
BeginNotify(pTooltipData);
}
else EndNotifyAll();
return 0;
}
int CTooltipNotify::ProtoAck(WPARAM, LPARAM lParam)
{
ACKDATA *ack = (ACKDATA*)lParam;
if ((ack == NULL) || (ack->type != ACKTYPE_STATUS)) return 0;
WORD wNewStatus = (WORD)ack->lParam;
WORD wOldStatus = (UINT_PTR)ack->hProcess;
if (wOldStatus == wNewStatus) return 0; //Useless message.
char *szProtocol = (char *)ack->szModule;
if (wNewStatus == ID_STATUS_OFFLINE) {
BYTE bProtoActive = db_get_b(NULL, MODULENAME, szProtocol, ProtoUserBit | ProtoIntBit);
bProtoActive &= ~ProtoIntBit;
db_set_b(NULL, MODULENAME, szProtocol, bProtoActive);
}
else {
if (wOldStatus < ID_STATUS_ONLINE && wNewStatus > ID_STATUS_OFFLINE) {
UINT_PTR idTimer = SetTimer(0, 0, m_sOptions.wStartupDelay * 1000, ConnectionTimerProcWrapper);
ProtoData protoData = { _strdup(szProtocol), idTimer };
m_mapTimerIdProto.push_back(protoData);
}
}
return 0;
}
int CTooltipNotify::ContactSettingChanged(WPARAM hContact, LPARAM lParam)
{
DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING*)lParam;
if (!hContact)
return 0;
bool idle = false;
if (strcmp(cws->szSetting, "Status") == 0)
idle = false;
else if (strcmp(cws->szSetting, "IdleTS") == 0)
idle = true;
else return 0;
if (db_get_b(hContact, "CList", "Hidden", 0))
return 0;
const char *pszProto = cws->szModule;
if (db_get_b(NULL, MODULENAME, pszProto, ProtoUserBit | ProtoIntBit) != (ProtoUserBit | ProtoIntBit))
return 0;
if (db_get_b(hContact, "CList", "NotOnList", 0) && m_sOptions.bIgnoreUnknown)
return 0;
if (db_get_b(hContact, MODULENAME, CONTACT_IGNORE_TTNOTIFY, m_sOptions.bIgnoreNew))
return 0;
if (idle && !m_sOptions.bIdle)
return 0;
WORD wNewStatus = cws->value.wVal;
switch (wNewStatus) {
case ID_STATUS_OFFLINE:
if (!m_sOptions.bOffline) return 0;
SkinPlaySound(SND_OFFLINE);
break;
case ID_STATUS_ONLINE:
if (CallService(MS_IGNORE_ISIGNORED, hContact, IGNOREEVENT_USERONLINE) && m_sOptions.bConjSOLN) return 0;
if (!m_sOptions.bOnline) return 0;
SkinPlaySound(SND_ONLINE);
break;
default:
if (!m_sOptions.bOther) return 0;
SkinPlaySound(SND_OTHER);
break;
}
STooltipData *pTooltipData = new STooltipData;
pTooltipData->uiTimeout = m_sOptions.wDuration * (wNewStatus == ID_STATUS_ONLINE ? (m_sOptions.bX2 + 1) : 1);
pTooltipData->hContact = hContact;
if (idle) wNewStatus = (wNewStatus != 0 ? ID_TTNTF_STATUS_IDLE : ID_TTNTF_STATUS_NOT_IDLE);
pTooltipData->iStatus = wNewStatus;
EndNotifyAll();
BeginNotify(pTooltipData);
return 0;
}
int CTooltipNotify::InitializeOptions(WPARAM wParam, LPARAM)
{
OPTIONSDIALOGPAGE odp = { 0 };
odp.position = 100000000;
odp.hInstance = g_hInstDLL;
odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTIONS);
odp.pszTitle = LPGEN("Tooltip Notify");
odp.pszGroup = LPGEN("Popups");
odp.groupPosition = 910000000;
odp.flags = ODPF_BOLDGROUPS;
odp.pfnDlgProc = CTooltipNotify::OptionsDlgProcWrapper;
::Options_AddPage(wParam, &odp);
return 0;
}
CTooltip *CTooltipNotify::BeginNotify(STooltipData *pTooltipData)
{
TCHAR szTooltipText[64] = { 0 };
MakeTooltipString(pTooltipData->hContact, pTooltipData->iStatus, szTooltipText, 64);
LOGFONT lf = { 0 };
COLORREF textColor = 0;
COLORREF bgColor = 0;
GetFont(pTooltipData->iStatus, &lf, &textColor, &bgColor);
CTooltip *pTooltip = new CTooltip(this);
pTooltip->set_Text(szTooltipText);
pTooltip->set_Font(lf);
pTooltip->set_BgColor(bgColor);
pTooltip->set_TextColor(textColor);
if (m_bNt50 && m_sOptions.bTransp)
pTooltip->set_Translucency(m_sOptions.bAlpha);
pTooltip->set_TransparentInput(m_bNt50 && m_sOptions.bTransp && m_sOptions.bTranspInput);
pTooltip->Validate();
RECT TooltipRect, WorkAreaRect;
SystemParametersInfo(SPI_GETWORKAREA, 0, &WorkAreaRect, 0);
pTooltip->get_Rect(&TooltipRect);
if (m_sOptions.bAutoPos || Utils_RestoreWindowPosition(pTooltip->GetHandle(), 0, MODULENAME, "toolwindow", RWPF_NOSIZE | RWPF_NOACTIVATE))
pTooltip->set_Position(WorkAreaRect.right - 10 - (TooltipRect.right - TooltipRect.left), WorkAreaRect.bottom - 2 - (TooltipRect.bottom - TooltipRect.top));
UINT_PTR idTimer = SetTimer(0, 0, pTooltipData->uiTimeout, TooltipTimerProcWrapper);
pTooltipData->idTimer = idTimer;
pTooltipData->pTooltip = pTooltip;
m_TooltipsList.push_back(pTooltipData);
pTooltip->Show();
return pTooltip;
}
BOOL CTooltipNotify::EndNotify(STooltipData* pTooltipData)
{
CTooltip* pTooltip = pTooltipData->pTooltip;
// return if the tooltip timer suspended
if (pTooltipData->idTimer == 0) return FALSE;
SuspendTimer(pTooltip);
pTooltip->Hide();
delete pTooltip;
delete pTooltipData;
m_TooltipsList.erase(
std::remove(m_TooltipsList.begin(), m_TooltipsList.end(), pTooltipData),
m_TooltipsList.end());
return TRUE;
}
void CTooltipNotify::EndNotifyAll()
{
// iterate through active tooltips and
// remove one which do not have its timer suspended
TooltipsList::reverse_iterator mapRevIter = m_TooltipsList.rbegin();
while (mapRevIter != m_TooltipsList.rend()) {
STooltipData* pTooltipData = *mapRevIter;
if (EndNotify(pTooltipData)) {
mapRevIter = m_TooltipsList.rbegin();
}
else {
++mapRevIter;
}
}
}
CTooltipNotify::MapTimerIdProtoIter CTooltipNotify::FindProtoByTimer(UINT idTimer)
{
for (
MapTimerIdProtoIter iter = m_mapTimerIdProto.begin();
iter != m_mapTimerIdProto.end();
++iter) {
if (iter->timerId == idTimer) {
return iter;
}
}
return m_mapTimerIdProto.end();
}
void CTooltipNotify::OnConnectionTimer(HWND, UINT, UINT_PTR idEvent, DWORD)
{
BOOL bSuccess = KillTimer(0, idEvent);
assert(bSuccess);
MapTimerIdProtoIter iter = FindProtoByTimer(idEvent);
assert(iter != m_mapTimerIdProto.end());
BYTE bProtoActive = db_get_b(NULL, MODULENAME, iter->proto, ProtoUserBit | ProtoIntBit);
bProtoActive |= ProtoIntBit;
db_set_b(NULL, MODULENAME, iter->proto, bProtoActive);
free((char*)iter->proto);
m_mapTimerIdProto.erase(iter);
}
void CTooltipNotify::OnTooltipTimer(HWND, UINT, UINT_PTR idEvent, DWORD)
{
TooltipsList::iterator iter = FindBy(&STooltipData::idTimer, idEvent);
assert(iter != m_TooltipsList.end());
STooltipData* pTooltipData = *iter;
EndNotify(pTooltipData);
}
/////////////////////////////////////////////////////////////////////////////////////////
struct
{
const char *szOldSetting, *szNewSetting;
}
static arSettings[] =
{
{ "xpos", "toolwindowx" },
{ "ypos", "toolwindowy" }
};
void CTooltipNotify::MigrateSettings()
{
for (int i = 0; i < _countof(arSettings); i++) {
int val = db_get_w(NULL, MODULENAME, arSettings[i].szOldSetting, -1);
if (val != -1) {
db_set_w(NULL, MODULENAME, arSettings[i].szNewSetting, val);
db_unset(NULL, MODULENAME, arSettings[i].szOldSetting);
}
}
}
/////////////////////////////////////////////////////////////////////////////////////////
void CTooltipNotify::LoadSettings()
{
m_sOptions.bFirstRun = db_get_b(NULL, MODULENAME, "firstrun", DEF_SETTING_FIRSTRUN);
m_sOptions.bOffline = db_get_b(NULL, MODULENAME, "offline", DEF_SETTING_OFFLINE);
m_sOptions.bOnline = db_get_b(NULL, MODULENAME, "online", DEF_SETTING_ONLINE);
m_sOptions.bOther = db_get_b(NULL, MODULENAME, "other", DEF_SETTING_OTHER);
m_sOptions.bTyping = db_get_b(NULL, MODULENAME, "typing", DEF_SETTING_TYPING);
m_sOptions.bIdle = db_get_b(NULL, MODULENAME, "idle", DEF_SETTING_TYPING);
m_sOptions.bX2 = db_get_b(NULL, MODULENAME, "x2", DEF_SETTING_X2);
m_sOptions.bConjSOLN = db_get_b(NULL, MODULENAME, "conjsoln", DEF_SETTING_CONJSOLN);
m_sOptions.bAutoPos = db_get_b(NULL, MODULENAME, "autopos", DEF_SETTING_DEF_POS);
m_sOptions.bBallonTip = db_get_b(NULL, MODULENAME, "balloontip", DEF_SETTING_BALLONTIP);
m_sOptions.bTransp = db_get_b(NULL, MODULENAME, "transp", DEF_SETTING_TRANSP);
m_sOptions.bAlpha = db_get_b(NULL, MODULENAME, "alpha", DEF_SETTING_ALPHA);
m_sOptions.bTranspInput = db_get_b(NULL, MODULENAME, "transpinput", DEF_SETTING_TRANSP_INPUT);
m_sOptions.bPrefixProto = db_get_b(NULL, MODULENAME, "prfxproto", DEF_SETTING_PREFIX_PROTO);
m_sOptions.bLDblClick = db_get_b(NULL, MODULENAME, "ldblclick", DEF_SETTING_LDBLCLICK);
m_sOptions.wDuration = db_get_w(NULL, MODULENAME, "duration", DEF_SETTING_DURATION);
m_sOptions.wStartupDelay = db_get_w(NULL, MODULENAME, "suprconndelay", DEF_SETTING_STARTUP_DELAY);
m_sOptions.bIgnoreUnknown = db_get_b(NULL, MODULENAME, "ignoreunknown", DEF_SETTING_IGNORE_UNKNOWN);
m_sOptions.bIgnoreNew = db_get_b(NULL, MODULENAME, "ignorenew", DEF_SETTING_IGNORE_NEW);
}
void CTooltipNotify::SaveSettings()
{
db_set_w(NULL, MODULENAME, "duration", m_sOptions.wDuration);
db_set_w(NULL, MODULENAME, "suprconndelay", m_sOptions.wStartupDelay);
db_set_b(NULL, MODULENAME, "offline", m_sOptions.bOffline);
db_set_b(NULL, MODULENAME, "online", m_sOptions.bOnline);
db_set_b(NULL, MODULENAME, "other", m_sOptions.bOther);
db_set_b(NULL, MODULENAME, "typing", m_sOptions.bTyping);
db_set_b(NULL, MODULENAME, "idle", m_sOptions.bIdle);
db_set_b(NULL, MODULENAME, "prfxproto", m_sOptions.bPrefixProto);
db_set_b(NULL, MODULENAME, "x2", m_sOptions.bX2);
db_set_b(NULL, MODULENAME, "conjsoln", m_sOptions.bConjSOLN);
db_set_b(NULL, MODULENAME, "autopos", m_sOptions.bAutoPos);
db_set_b(NULL, MODULENAME, "balloontip", m_sOptions.bBallonTip);
db_set_b(NULL, MODULENAME, "transp", m_sOptions.bTransp);
db_set_b(NULL, MODULENAME, "alpha", m_sOptions.bAlpha);
db_set_b(NULL, MODULENAME, "transpinput", m_sOptions.bTranspInput);
db_set_b(NULL, MODULENAME, "ldblclick", m_sOptions.bLDblClick);
db_set_b(NULL, MODULENAME, "ignoreunknown", m_sOptions.bIgnoreUnknown);
db_set_b(NULL, MODULENAME, "ignorenew", m_sOptions.bIgnoreNew);
}
void CTooltipNotify::ReadSettingsFromDlg(HWND hDlg)
{
m_sOptions.bOffline = (BYTE)(IsDlgButtonChecked(hDlg, IDC_OFFLINE) == BST_CHECKED ? 1 : 0);
m_sOptions.bOnline = (BYTE)(IsDlgButtonChecked(hDlg, IDC_ONLINE) == BST_CHECKED ? 1 : 0);
m_sOptions.bOther = (BYTE)(IsDlgButtonChecked(hDlg, IDC_OTHER) == BST_CHECKED ? 1 : 0);
m_sOptions.bTyping = (BYTE)(IsDlgButtonChecked(hDlg, IDC_TYPING) == BST_CHECKED ? 1 : 0);
m_sOptions.bIdle = (BYTE)(IsDlgButtonChecked(hDlg, IDC_IDLE) == BST_CHECKED ? 1 : 0);
m_sOptions.bX2 = (BYTE)(IsDlgButtonChecked(hDlg, IDC_X2) == BST_CHECKED ? 1 : 0);
m_sOptions.bConjSOLN = (BYTE)(IsDlgButtonChecked(hDlg, IDC_CONJSOLN) == BST_CHECKED ? 1 : 0);
m_sOptions.bAutoPos = (BYTE)(IsDlgButtonChecked(hDlg, IDC_AUTOPOS) == BST_CHECKED ? 1 : 0);
m_sOptions.bBallonTip = (BYTE)(IsDlgButtonChecked(hDlg, IDC_BALLONTIP) == BST_CHECKED ? 1 : 0);
m_sOptions.bTransp = (BYTE)(IsDlgButtonChecked(hDlg, IDC_TRANSPARENCY) == BST_CHECKED ? 1 : 0);
m_sOptions.bAlpha = (BYTE)SendDlgItemMessage(hDlg, IDC_TRANSPARENCY_SLIDER, TBM_GETPOS, 0, 0);
m_sOptions.bTranspInput = (BYTE)(IsDlgButtonChecked(hDlg, IDC_TRANSP_INPUT) == BST_CHECKED ? 1 : 0);
m_sOptions.bPrefixProto = (BYTE)(IsDlgButtonChecked(hDlg, IDC_PREFIX_PROTO) == BST_CHECKED ? 1 : 0);
m_sOptions.bLDblClick = (BYTE)(IsDlgButtonChecked(hDlg, IDC_RB_CLIST) == BST_CHECKED) ? SHOW_HIDE_CLIST : OPEN_MSGDLG;
m_sOptions.wDuration = LOWORD(SendDlgItemMessage(hDlg, IDC_DURATIONSPIN, UDM_GETPOS, 0, 0));
m_sOptions.wStartupDelay = LOWORD(SendDlgItemMessage(hDlg, IDC_DELAYONCONNSPIN, UDM_GETPOS, 0, 0));
}
void CTooltipNotify::WriteSettingsToDlg(HWND hDlg)
{
SendDlgItemMessage(hDlg, IDC_DURATIONSPIN, UDM_SETRANGE, 0, MAKELONG(550 * 36, 550));
SendDlgItemMessage(hDlg, IDC_DURATIONSPIN, UDM_SETPOS, 0, MAKELONG(m_sOptions.wDuration, 0));
SendDlgItemMessage(hDlg, IDC_DELAYONCONNSPIN, UDM_SETRANGE, 0, MAKELONG(30, 0));
SendDlgItemMessage(hDlg, IDC_DELAYONCONNSPIN, UDM_SETPOS, 0, MAKELONG(m_sOptions.wStartupDelay, 0));
CheckDlgButton(hDlg, IDC_OFFLINE, m_sOptions.bOffline ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hDlg, IDC_ONLINE, m_sOptions.bOnline ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hDlg, IDC_OTHER, m_sOptions.bOther ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hDlg, IDC_TYPING, m_sOptions.bTyping ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hDlg, IDC_IDLE, m_sOptions.bIdle ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hDlg, IDC_PREFIX_PROTO, m_sOptions.bPrefixProto ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hDlg, IDC_X2, m_sOptions.bX2 ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hDlg, IDC_CONJSOLN, m_sOptions.bConjSOLN ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hDlg, IDC_AUTOPOS, m_sOptions.bAutoPos ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hDlg, IDC_BALLONTIP, m_sOptions.bBallonTip ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hDlg, IDC_TRANSPARENCY, m_sOptions.bTransp ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hDlg, IDC_TRANSP_INPUT, m_sOptions.bTranspInput ? BST_CHECKED : BST_UNCHECKED);
switch (m_sOptions.bLDblClick) {
case SHOW_HIDE_CLIST: CheckDlgButton(hDlg, IDC_RB_CLIST, BST_CHECKED); break;
case OPEN_MSGDLG: CheckDlgButton(hDlg, IDC_RB_MSGDLG, BST_CHECKED); break;
default: CheckDlgButton(hDlg, IDC_RB_CLIST, BST_CHECKED); break;
}
EnableWindow(GetDlgItem(hDlg, IDC_GB_TRANSP), m_bNt50);
EnableWindow(GetDlgItem(hDlg, IDC_TRANSPARENCY), m_bNt50);
EnableWindow(GetDlgItem(hDlg, IDC_TRANSPARENCY_SLIDER), m_sOptions.bTransp && m_bNt50);
EnableWindow(GetDlgItem(hDlg, IDC_TRANSPERC), m_sOptions.bTransp && m_bNt50);
EnableWindow(GetDlgItem(hDlg, IDC_TRANSP_INPUT), m_sOptions.bTransp && m_bNt50);
EnableWindow(GetDlgItem(hDlg, IDC_RB_CLIST), !m_sOptions.bTranspInput);
EnableWindow(GetDlgItem(hDlg, IDC_RB_MSGDLG), !m_sOptions.bTranspInput);
SendDlgItemMessage(hDlg, IDC_TRANSPARENCY_SLIDER, TBM_SETRANGE, FALSE, MAKELONG(1, 255));
SendDlgItemMessage(hDlg, IDC_TRANSPARENCY_SLIDER, TBM_SETPOS, TRUE, m_sOptions.bAlpha);
}
void CTooltipNotify::ValidateSettings()
{
if (m_sOptions.wStartupDelay > 30) m_sOptions.wStartupDelay = 30;
if (m_sOptions.wDuration > 550 * 36) m_sOptions.wDuration = 550 * 36;
if (m_sOptions.wDuration < 550 * 1) m_sOptions.wDuration = 550 * 1;
if (!m_sOptions.bTransp) m_sOptions.bTranspInput = 0;
}
// main options dialog
BOOL CTooltipNotify::OptionsDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg) {
case WM_INITDIALOG:
TranslateDialogDefault(hDlg);
WriteSettingsToDlg(hDlg);
SendMessage(hDlg, WM_HSCROLL, 0x12345678, 0);
return TRUE;
case WM_VSCROLL:
case WM_HSCROLL:
TCHAR str[10];
mir_sntprintf(str, L"%d%%", 100 * SendDlgItemMessage(hDlg, IDC_TRANSPARENCY_SLIDER, TBM_GETPOS, 0, 0) / 255);
SetDlgItemText(hDlg, IDC_TRANSPERC, str);
if (wParam != 0x12345678)
SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0);
return TRUE;
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDC_TRANSPARENCY:
EnableWindow(GetDlgItem(hDlg, IDC_TRANSPERC), IsDlgButtonChecked(hDlg, IDC_TRANSPARENCY) == BST_CHECKED);
EnableWindow(GetDlgItem(hDlg, IDC_TRANSPARENCY_SLIDER), IsDlgButtonChecked(hDlg, IDC_TRANSPARENCY) == BST_CHECKED);
EnableWindow(GetDlgItem(hDlg, IDC_TRANSP_INPUT), IsDlgButtonChecked(hDlg, IDC_TRANSPARENCY) == BST_CHECKED);
CheckDlgButton(hDlg, IDC_TRANSP_INPUT, IsDlgButtonChecked(hDlg, IDC_TRANSPARENCY) == BST_CHECKED ? (m_sOptions.bTranspInput ? BST_CHECKED : BST_UNCHECKED) : BST_UNCHECKED);
SendMessage(hDlg, WM_COMMAND, MAKEWPARAM(IDC_TRANSP_INPUT, 0), 0);
SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0);
break;
case IDC_TRANSP_INPUT:
//EnableWindow(GetDlgItem(hDlg,IDC_GB_DBLCLICK), IsDlgButtonChecked(hDlg, IDC_TRANSP_INPUT));
EnableWindow(GetDlgItem(hDlg, IDC_RB_CLIST), !(IsDlgButtonChecked(hDlg, IDC_TRANSP_INPUT) == BST_CHECKED));
EnableWindow(GetDlgItem(hDlg, IDC_RB_MSGDLG), !(IsDlgButtonChecked(hDlg, IDC_TRANSP_INPUT) == BST_CHECKED));
SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0);
break;
case IDC_BALLONTIP:
EnableWindow(GetDlgItem(hDlg, IDC_DURATION), !(IsDlgButtonChecked(hDlg, IDC_BALLONTIP) == BST_CHECKED));
EnableWindow(GetDlgItem(hDlg, IDC_X2), !(IsDlgButtonChecked(hDlg, IDC_BALLONTIP) == BST_CHECKED));
EnableWindow(GetDlgItem(hDlg, IDC_RB_CLIST), !(IsDlgButtonChecked(hDlg, IDC_BALLONTIP) == BST_CHECKED));
EnableWindow(GetDlgItem(hDlg, IDC_RB_MSGDLG), !(IsDlgButtonChecked(hDlg, IDC_BALLONTIP) == BST_CHECKED));
EnableWindow(GetDlgItem(hDlg, IDC_TRANSP_INPUT), !(IsDlgButtonChecked(hDlg, IDC_BALLONTIP) == BST_CHECKED));
EnableWindow(GetDlgItem(hDlg, IDC_AUTOPOS), !(IsDlgButtonChecked(hDlg, IDC_BALLONTIP) == BST_CHECKED));
SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0);
break;
case IDC_DURATION:
if (HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus()) return FALSE;
SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0);
break;
case IDC_DELAYONCONN:
if (HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus()) return FALSE;
SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0);
break;
case IDC_PREVIEW:
{
STooltipData *pTooltipData = new STooltipData;
pTooltipData->uiTimeout = m_sOptions.wDuration * (m_sOptions.bX2 ? (m_sOptions.bX2 + 1) : 1);
pTooltipData->hContact = 0;
pTooltipData->iStatus = ID_STATUS_ONLINE;
EndNotifyAll();
BeginNotify(pTooltipData);
break;
}
case IDC_SEL_PROTO:
DialogBox(g_hInstDLL, MAKEINTRESOURCE(IDD_PROTOS), hDlg, CTooltipNotify::ProtosDlgProcWrapper);
break;
case IDC_IGNORE:
DialogBox(g_hInstDLL, MAKEINTRESOURCE(IDD_CONTACTS), hDlg, CTooltipNotify::ContactsDlgProcWrapper);
break;
default:
// activate 'apply' button
SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0);
return TRUE;
}
return TRUE;
case WM_NOTIFY:
// Here we have pressed either the OK or the APPLY button.
switch (((LPNMHDR)lParam)->idFrom) {
case 0:
switch (((LPNMHDR)lParam)->code) {
case PSN_APPLY:
ReadSettingsFromDlg(hDlg);
SaveSettings();
return TRUE;
} // switch code
break;
} //switch idFrom
return TRUE;
}
return FALSE;
}
// dialog for protocols selecting
BOOL CTooltipNotify::ProtosDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM)
{
switch (msg) {
case WM_INITDIALOG:
TranslateDialogDefault(hDlg);
{
ListView_SetExtendedListViewStyle(GetDlgItem(hDlg, IDC_PROTOS), LVS_EX_CHECKBOXES);
// enum protocols currently running
int iProtoCount = 0;
PROTOACCOUNT **ppProtos = 0;
Proto_EnumAccounts(&iProtoCount, &ppProtos);
// and fill in the list
for (int i = 0; i < iProtoCount; i++) {
LV_ITEM lvi;
lvi.mask = LVIF_TEXT;
lvi.iSubItem = 0;
lvi.iItem = i;
lvi.lParam = i;
WCHAR wszProto[128];
long lLen = MultiByteToWideChar(CP_ACP, 0, ppProtos[i]->szModuleName,
(int)mir_strlen(ppProtos[i]->szModuleName), wszProto, _countof(wszProto));
wszProto[lLen] = L'\0';
lvi.pszText = wszProto;
ListView_InsertItem(GetDlgItem(hDlg, IDC_PROTOS), &lvi);
BYTE bProtoState = db_get_b(NULL, MODULENAME, ppProtos[i]->szModuleName, ProtoUserBit | ProtoIntBit);
BOOL bProtoEnabled = (bProtoState & ProtoUserBit) != 0;
ListView_SetCheckState(GetDlgItem(hDlg, IDC_PROTOS), i, bProtoEnabled);
}
}
return TRUE;
case WM_COMMAND:
if (LOWORD(wParam) == IDOK) {
int proto_count = ListView_GetItemCount(GetDlgItem(hDlg, IDC_PROTOS));
for (int i = 0; i < proto_count; i++) {
TCHAR szProto[64];
ListView_GetItemText(GetDlgItem(hDlg, IDC_PROTOS), i, 0, szProto, _countof(szProto));
char szMultiByteProto[128];
long lLen = WideCharToMultiByte(CP_ACP, 0, szProto, (int)mir_tstrlen(szProto),
szMultiByteProto, sizeof(szMultiByteProto), NULL, NULL);
szMultiByteProto[lLen] = '\0';
BYTE bProtoState = db_get_b(NULL, MODULENAME, szMultiByteProto, ProtoUserBit | ProtoIntBit);
BOOL bProtoEnabled = ListView_GetCheckState(GetDlgItem(hDlg, IDC_PROTOS), i);
bProtoState = bProtoEnabled ? bProtoState | ProtoUserBit : bProtoState&~ProtoUserBit;
db_set_b(NULL, MODULENAME, szMultiByteProto, bProtoState);
}
EndDialog(hDlg, LOWORD(wParam));
return TRUE;
}
if (LOWORD(wParam) == IDCANCEL) {
EndDialog(hDlg, LOWORD(wParam));
return TRUE;
}
return TRUE;
case WM_CLOSE:
EndDialog(hDlg, LOWORD(wParam));
return TRUE;
}
return FALSE;
}
void CTooltipNotify::ResetCList(HWND hwndDlg)
{
SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_SETUSEGROUPS, db_get_b(NULL, "CList", "UseGroups", SETTING_USEGROUPS_DEFAULT), 0);
SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_SETHIDEEMPTYGROUPS, 1, 0);
}
void CTooltipNotify::LoadList(HWND hwndDlg, HANDLE hItemNew, HANDLE hItemUnknown)
{
if (hItemNew && !m_sOptions.bIgnoreNew)
SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_SETCHECKMARK, (WPARAM)hItemNew, 1);
if (hItemUnknown && !m_sOptions.bIgnoreUnknown)
SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_SETCHECKMARK, (WPARAM)hItemUnknown, 1);
for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
HANDLE hItem = (HANDLE)SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_FINDCONTACT, hContact, 0);
if (hItem && !db_get_b(hContact, MODULENAME, CONTACT_IGNORE_TTNOTIFY, m_sOptions.bIgnoreNew))
SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_SETCHECKMARK, (WPARAM)hItem, 1);
}
}
void CTooltipNotify::SaveList(HWND hwndDlg, HANDLE hItemNew, HANDLE hItemUnknown)
{
if (hItemNew)
m_sOptions.bIgnoreNew = (BYTE)(SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_GETCHECKMARK, (WPARAM)hItemNew, 0) ? 0 : 1);
if (hItemUnknown)
m_sOptions.bIgnoreUnknown = (BYTE)(SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_GETCHECKMARK, (WPARAM)hItemUnknown, 0) ? 0 : 1);
for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
HANDLE hItem = (HANDLE)SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_FINDCONTACT, hContact, 0);
if (hItem) {
BYTE bChecked = (BYTE)(SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_GETCHECKMARK, (WPARAM)hItem, 0));
db_set_b(hContact, MODULENAME, CONTACT_IGNORE_TTNOTIFY, bChecked ? 0 : 1);
}
}
}
// dialog for ignore tooltip notifications
BOOL CTooltipNotify::ContactsDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM)
{
static HANDLE hItemNew, hItemUnknown;
switch (msg) {
case WM_INITDIALOG:
TranslateDialogDefault(hDlg);
{
CLCINFOITEM cii = { 0 };
cii.cbSize = sizeof(cii);
cii.flags = CLCIIF_GROUPFONT | CLCIIF_CHECKBOX;
cii.pszText = TranslateT("** New contacts **");
hItemNew = (HANDLE)SendDlgItemMessage(hDlg, IDC_CLIST, CLM_ADDINFOITEM, 0, (LPARAM)& cii);
cii.pszText = TranslateT("** Unknown contacts **");
hItemUnknown = (HANDLE)SendDlgItemMessage(hDlg, IDC_CLIST, CLM_ADDINFOITEM, 0, (LPARAM)& cii);
ResetCList(hDlg);
LoadList(hDlg, hItemNew, hItemUnknown);
}
return TRUE;
case WM_COMMAND:
if (LOWORD(wParam) == IDOK) {
SaveList(hDlg, hItemNew, hItemUnknown);
EndDialog(hDlg, LOWORD(wParam));
return TRUE;
}
if (LOWORD(wParam) == IDCANCEL) {
EndDialog(hDlg, LOWORD(wParam));
return TRUE;
}
return TRUE;
case WM_CLOSE:
EndDialog(hDlg, LOWORD(wParam));
return TRUE;
}
return FALSE;
}
TCHAR* CTooltipNotify::StatusToString(int iStatus, TCHAR *szStatus, int iBufSize)
{
if (iStatus >= ID_STATUS_OFFLINE && iStatus <= ID_STATUS_OUTTOLUNCH)
mir_tstrncpy(szStatus, pcli->pfnGetStatusModeDescription(iStatus, 0), iBufSize);
else {
switch (iStatus) {
case ID_TTNTF_STATUS_TYPING:
mir_tstrncpy(szStatus, TranslateT("Typing"), iBufSize);
break;
case ID_TTNTF_STATUS_IDLE:
mir_tstrncpy(szStatus, TranslateT("Idle"), iBufSize);
break;
case ID_TTNTF_STATUS_NOT_IDLE:
mir_tstrncpy(szStatus, TranslateT("Not Idle"), iBufSize);
break;
default:
mir_tstrncpy(szStatus, TranslateT("Unknown"), iBufSize);
break;
}
}
return szStatus;
}
TCHAR* CTooltipNotify::MakeTooltipString(MCONTACT hContact, int iStatus, TCHAR *szString, int iBufSize)
{
TCHAR szStatus[32];
StatusToString(iStatus, szStatus, _countof(szStatus));
// "proro: user is online"
const TCHAR *szFormatString = m_sOptions.bPrefixProto ? L"%s%s%s" : L"%.0s%.0s%s";
const TCHAR* szIs = TranslateT("is");
const char* szProto = hContact == 0 ? "Proto" : ::GetContactProto(hContact);
const TCHAR* szContactName = ::pcli->pfnGetContactDisplayName(hContact, 0);
memset(szString, 0, iBufSize*sizeof(TCHAR));
WCHAR wszProto[32];
long lLen = MultiByteToWideChar(CP_ACP, 0, szProto, (int)mir_strlen(szProto), wszProto, _countof(wszProto));
wszProto[lLen] = _T('\0');
mir_sntprintf(szString, iBufSize - 1, szFormatString, wszProto, L": ", szContactName);
TruncateWithDots(szString, iBufSize - 1 - mir_tstrlen(szStatus) - mir_tstrlen(szIs) - 2); // 2 spaces around szIs
mir_sntprintf(szString + mir_tstrlen(szString), iBufSize - 1 - mir_tstrlen(szString), L" %s %s", szIs, szStatus);
return szString;
}
void CTooltipNotify::OnTooltipDblClicked(CTooltip *pTooltip)
{
switch (m_sOptions.bLDblClick) {
case SHOW_HIDE_CLIST:
::CallService(MS_CLIST_SHOWHIDE, 0, 0);
break;
case OPEN_MSGDLG:
{
TooltipsList::iterator iter = FindBy(&STooltipData::pTooltip, pTooltip);
STooltipData* pTooltipData = *iter;
WPARAM wParam = (WPARAM)pTooltipData->hContact;
if (wParam) ::CallService(MS_CLIST_CONTACTDOUBLECLICKED, wParam, 0);
break;
}
default:
::CallService(MS_CLIST_SHOWHIDE, 0, 0);
break;
}
}
BOOL CTooltipNotify::OnTooltipBeginMove(CTooltip *pTooltip)
{
if (m_sOptions.bAutoPos) return FALSE;
SuspendTimer(pTooltip);
return TRUE;
}
void CTooltipNotify::OnTooltipEndMove(CTooltip *pTooltip)
{
Utils_SaveWindowPosition(pTooltip->GetHandle(), NULL, MODULENAME, "toolwindow");
ResumeTimer(pTooltip);
}
void CTooltipNotify::SuspendTimer(CTooltip *pTooltip)
{
TooltipsList::iterator iter = FindBy(&STooltipData::pTooltip, pTooltip);
assert(iter != m_TooltipsList.end());
STooltipData* pTooltipData = *iter;
BOOL bSuccess = KillTimer(0, pTooltipData->idTimer);
assert(bSuccess);
pTooltipData->idTimer = 0; // denote that the timer is inactive
}
void CTooltipNotify::ResumeTimer(CTooltip *pTooltip)
{
TooltipsList::iterator iter = FindBy(&STooltipData::pTooltip, pTooltip);
assert(iter != m_TooltipsList.end());
STooltipData* pTooltipData = *iter;
UINT_PTR idTimer = SetTimer(0, 0, pTooltipData->uiTimeout, TooltipTimerProcWrapper);
pTooltipData->idTimer = idTimer;
}
template<typename T>
CTooltipNotify::TooltipsList::iterator CTooltipNotify::FindBy(T STooltipData::* field, const T& value)
{
for (TooltipsList::iterator iter = m_TooltipsList.begin(); iter != m_TooltipsList.end(); ++iter) {
STooltipData *pTooltipData = *iter;
if (pTooltipData->*field == value)
return iter;
}
return m_TooltipsList.end();
}
|