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
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
|
/*
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"
#define IDI_BLANK 200
void LoadSettings(void);
extern uint8_t
bFlashOnMsg, bFlashOnFile, bFlashOnGC, bFlashOnOther, bFullScreenMode, bScreenSaverRunning, bWorkstationLocked, bProcessesAreRunning,
bWorkstationActive, bFlashIfMsgOpen, bFlashIfMsgOlder, bFlashUntil, bMirandaOrWindows, bFlashLed[3], bFlashEffect, bSequenceOrder, bFlashSpeed,
bEmulateKeypresses, bOverride, bFlashIfMsgWinNotTop, bTrillianLedsMsg, bTrillianLedsURL, bTrillianLedsFile, bTrillianLedsOther;
extern uint16_t wSecondsOlder, wBlinksNumber, wStatusMap, wReminderCheck, wCustomTheme, wStartDelay;
extern PROTOCOL_LIST ProtoList;
extern PROCESS_LIST ProcessList;
HWND hwndProto, hwndBasic, hwndEffect, hwndTheme, hwndIgnore, hwndCurrentTab;
wchar_t *AttendedName[] = { L"Miranda", L"Windows" };
wchar_t *OrderName[] = { LPGENW("left -> right"), LPGENW("right -> left"), LPGENW("left <-> right") };
PROCESS_LIST ProcessListAux;
XSTATUS_INFO *XstatusListAux;
uint8_t trillianLedsMsg, trillianLedsURL, trillianLedsFile, trillianLedsOther;
static void writeThemeToCombo(const wchar_t *theme, const wchar_t *custom, BOOL overrideExisting)
{
int item = SendDlgItemMessage(hwndTheme, IDC_THEME, CB_FINDSTRINGEXACT, -1, (LPARAM)theme);
if (item == CB_ERR) {
item = SendDlgItemMessage(hwndTheme, IDC_THEME, CB_ADDSTRING, 0, (LPARAM)theme);
wchar_t *str = mir_wstrdup(custom);
SendDlgItemMessage(hwndTheme, IDC_THEME, CB_SETITEMDATA, (WPARAM)item, (LPARAM)str);
}
else if (overrideExisting) {
wchar_t *str = (wchar_t *)SendDlgItemMessage(hwndTheme, IDC_THEME, CB_GETITEMDATA, (WPARAM)item, 0);
if (str)
mir_wstrcpy(str, custom);
}
}
void exportThemes(const wchar_t *filename)
{
FILE *fExport = _wfopen(filename, L"wt");
if (!fExport)
return;
fwprintf(fExport, TranslateT("\n; Automatically generated Keyboard Notify Theme file\n\n\n"));
wchar_t *szTheme;
for (int i = 0; szTheme = g_plugin.getWStringA(fmtDBSettingName("theme%d", i)); i++) {
fwprintf(fExport, L"[%s]\n", szTheme);
mir_free(szTheme);
if (szTheme = g_plugin.getWStringA(fmtDBSettingName("custom%d", i))) {
fwprintf(fExport, L"%s\n\n", szTheme);
mir_free(szTheme);
}
else fwprintf(fExport, L"0\n\n");
}
fwprintf(fExport, TranslateT("\n; End of automatically generated Keyboard Notify Theme file\n"));
fclose(fExport);
}
void importThemes(const wchar_t *filename, BOOL overrideExisting)
{
FILE *fImport = _wfopen(filename, L"rt");
if (!fImport)
return;
int status = 0;
size_t i;
wchar_t buffer[MAX_PATH + 1], theme[MAX_PATH + 1], *str;
while (fgetws(buffer, MAX_PATH, fImport) != nullptr) {
for (str = buffer; *str && isspace(*str); str++); //ltrim
if (!*str || *str == ';') //empty line or comment
continue;
for (i = mir_wstrlen(str) - 1; isspace(str[i]); str[i--] = '\0'); //rtrim
switch (status) {
case 0:
if (i > 1 && str[0] == '[' && str[i] == ']') {
status = 1;
mir_wstrcpy(theme, str + 1);
theme[i - 1] = '\0';
}
break;
case 1:
status = 0;
writeThemeToCombo(theme, normalizeCustomString(str), overrideExisting);
break;
}
}
fclose(fImport);
}
static void createProcessListAux(void)
{
ProcessListAux.count = ProcessList.count;
ProcessListAux.szFileName = (wchar_t **)mir_alloc(ProcessListAux.count * sizeof(wchar_t *));
if (ProcessListAux.szFileName) {
for (int i = 0; i < ProcessListAux.count; i++) {
if (!ProcessList.szFileName[i])
ProcessListAux.szFileName[i] = nullptr;
else
ProcessListAux.szFileName[i] = mir_wstrdup(ProcessList.szFileName[i]);
}
}
else ProcessListAux.count = 0;
}
static void destroyProcessListAux(void)
{
if (ProcessListAux.szFileName == nullptr)
return;
for (int i = 0; i < ProcessListAux.count; i++)
if (ProcessListAux.szFileName[i])
mir_free(ProcessListAux.szFileName[i]);
mir_free(ProcessListAux.szFileName);
ProcessListAux.count = 0;
ProcessListAux.szFileName = nullptr;
}
static void createXstatusListAux(void)
{
XstatusListAux = (XSTATUS_INFO *)mir_alloc(ProtoList.protoCount * sizeof(XSTATUS_INFO));
if (XstatusListAux)
for (int i = 0; i < ProtoList.protoCount; i++) {
XstatusListAux[i].count = ProtoList.protoInfo[i].xstatus.count;
if (!XstatusListAux[i].count)
XstatusListAux[i].enabled = nullptr;
else {
XstatusListAux[i].enabled = (BOOL *)mir_alloc(XstatusListAux[i].count * sizeof(BOOL));
if (!XstatusListAux[i].enabled)
XstatusListAux[i].count = 0;
else
for (int j = 0; j < (int)XstatusListAux[i].count; j++)
XstatusListAux[i].enabled[j] = ProtoList.protoInfo[i].xstatus.enabled[j];
}
}
}
static void destroyXstatusListAux(void)
{
if (XstatusListAux) {
for (int i = 0; i < ProtoList.protoCount; i++)
if (XstatusListAux[i].enabled)
mir_free(XstatusListAux[i].enabled);
mir_free(XstatusListAux);
XstatusListAux = nullptr;
}
}
static INT_PTR CALLBACK DlgProcProcesses(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg) {
case WM_INITDIALOG:
TranslateDialogDefault(hwndDlg);
SendDlgItemMessage(hwndDlg, IDC_PROGRAMS, EM_LIMITTEXT, MAX_PATH, 0);
for (int i = 0; i < ProcessListAux.count; i++)
if (ProcessListAux.szFileName[i]) {
int index = SendDlgItemMessage(hwndDlg, IDC_PROGRAMS, CB_INSERTSTRING, (WPARAM)-1, (LPARAM)ProcessListAux.szFileName[i]);
if (index != CB_ERR && index != CB_ERRSPACE)
SendDlgItemMessage(hwndDlg, IDC_PROGRAMS, CB_SETITEMDATA, (WPARAM)index, (LPARAM)i);
}
EnableWindow(GetDlgItem(hwndDlg, IDC_ADDPGM), FALSE);
if (SendDlgItemMessage(hwndDlg, IDC_PROGRAMS, CB_GETCOUNT, 0, 0) == 0)
EnableWindow(GetDlgItem(hwndDlg, IDC_DELETEPGM), FALSE);
else
SendDlgItemMessage(hwndDlg, IDC_PROGRAMS, CB_SETCURSEL, 0, 0);
return TRUE;
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDC_PROGRAMS:
switch (HIWORD(wParam)) {
case CBN_SELENDOK:
case CBN_SELCHANGE:
EnableWindow(GetDlgItem(hwndDlg, IDC_ADDPGM), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_DELETEPGM), TRUE);
break;
case CBN_EDITCHANGE:
wchar_t szFileName[MAX_PATH + 1];
GetDlgItemText(hwndDlg, IDC_PROGRAMS, szFileName, _countof(szFileName));
int item = SendMessage((HWND)lParam, CB_FINDSTRINGEXACT, -1, (LPARAM)szFileName);
if (item == CB_ERR) { //new program
EnableWindow(GetDlgItem(hwndDlg, IDC_ADDPGM), TRUE);
EnableWindow(GetDlgItem(hwndDlg, IDC_DELETEPGM), FALSE);
}
else {
EnableWindow(GetDlgItem(hwndDlg, IDC_ADDPGM), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_DELETEPGM), TRUE);
}
break;
}
break;
case IDC_ADDPGM:
{
wchar_t szFileName[MAX_PATH + 1];
GetDlgItemText(hwndDlg, IDC_PROGRAMS, szFileName, _countof(szFileName));
if (!szFileName[0])
break;
SendDlgItemMessage(hwndDlg, IDC_PROGRAMS, CB_ADDSTRING, 0, (LPARAM)szFileName);
EnableWindow(GetDlgItem(hwndDlg, IDC_ADDPGM), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_DELETEPGM), TRUE);
}
break;
case IDC_DELETEPGM:
{
wchar_t szFileName[MAX_PATH + 1];
GetDlgItemText(hwndDlg, IDC_PROGRAMS, szFileName, _countof(szFileName));
int item = SendDlgItemMessage(hwndDlg, IDC_PROGRAMS, CB_FINDSTRINGEXACT, -1, (LPARAM)szFileName);
SendDlgItemMessage(hwndDlg, IDC_PROGRAMS, CB_DELETESTRING, (WPARAM)item, 0);
if (SendDlgItemMessage(hwndDlg, IDC_PROGRAMS, CB_GETCOUNT, 0, 0) == 0) {
SetDlgItemText(hwndDlg, IDC_PROGRAMS, L"");
EnableWindow(GetDlgItem(hwndDlg, IDC_DELETEPGM), FALSE);
}
else
SendDlgItemMessage(hwndDlg, IDC_PROGRAMS, CB_SETCURSEL, 0, 0);
}
break;
case IDC_OKPGM:
destroyProcessListAux();
ProcessListAux.count = SendDlgItemMessage(hwndDlg, IDC_PROGRAMS, CB_GETCOUNT, 0, 0);
ProcessListAux.szFileName = (wchar_t **)mir_alloc(ProcessListAux.count * sizeof(wchar_t *));
if (!ProcessListAux.szFileName)
ProcessListAux.count = 0;
else
for (int i = 0; i < ProcessListAux.count; i++) {
wchar_t szFileNameAux[MAX_PATH + 1];
SendDlgItemMessage(hwndDlg, IDC_PROGRAMS, CB_GETLBTEXT, (WPARAM)i, (LPARAM)szFileNameAux);
ProcessListAux.szFileName[i] = mir_wstrdup(szFileNameAux);
}
// fallthrough
case IDC_CANCELPGM:
EndDialog(hwndDlg, LOWORD(wParam));
break;
}
break;
}
return FALSE;
}
static INT_PTR CALLBACK DlgProcXstatusList(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM)
{
switch (msg) {
case WM_INITDIALOG:
TranslateDialogDefault(hwndDlg);
{
WPARAM j;
TVINSERTSTRUCT tvis = {};
TVITEM tvi = { 0 };
HTREEITEM hSectionItem, hItem;
HWND hwndTree = GetDlgItem(hwndDlg, IDC_TREE_XSTATUS);
SetWindowLongPtr(hwndTree, GWL_STYLE, GetWindowLongPtr(hwndTree, GWL_STYLE) | TVS_NOHSCROLL | TVS_CHECKBOXES);
if (!XstatusListAux) return TRUE;
// Calculate hImageList size
int imageCount = 1;
for (int i = 0; i < ProtoList.protoCount; i++)
if (ProtoList.protoInfo[i].enabled && XstatusListAux[i].count)
imageCount += XstatusListAux[i].count;
HIMAGELIST hImageList = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR32 | ILC_MASK, imageCount, imageCount);
TreeView_SetImageList(hwndTree, hImageList, TVSIL_NORMAL);
HICON hIconAux = (HICON)LoadImage(GetModuleHandle(nullptr), MAKEINTRESOURCE(IDI_BLANK), IMAGE_ICON, 0, 0, 0);
if (hIconAux) {
ImageList_AddIcon(hImageList, hIconAux);
DestroyIcon(hIconAux);
}
TreeView_SelectItem(hwndTree, NULL);
ShowWindow(hwndTree, SW_HIDE);
TreeView_DeleteAllItems(hwndTree);
for (int i = 0; i < ProtoList.protoCount; i++)
if (ProtoList.protoInfo[i].enabled && XstatusListAux[i].count) {
int count;
PROTOACCOUNT **protos;
Proto_EnumAccounts(&count, &protos);
tvis.hParent = nullptr;
tvis.hInsertAfter = TVI_LAST;
tvis.item.mask = TVIF_TEXT | TVIF_PARAM | TVIF_STATE | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
tvis.item.pszText = protos[i]->tszAccountName;
tvis.item.lParam = (LPARAM)i;
tvis.item.stateMask = TVIS_BOLD | TVIS_EXPANDED;
tvis.item.state = TVIS_BOLD | TVIS_EXPANDED;
tvis.item.iImage = tvis.item.iSelectedImage = ImageList_AddIcon(hImageList, hIconAux = (HICON)CallProtoService(ProtoList.protoInfo[i].szProto, PS_LOADICON, PLI_PROTOCOL, 0));
if (hIconAux) DestroyIcon(hIconAux);
HTREEITEM hParent = TreeView_InsertItem(hwndTree, &tvis);
for (j = 0; j < XstatusListAux[i].count; j++) {
tvis.hParent = hParent;
tvis.item.mask = TVIF_TEXT | TVIF_PARAM | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
if (!j) {
tvis.item.pszText = TranslateT("None");
}
else {
wchar_t szDefaultName[1024];
CUSTOM_STATUS xstatus = { 0 };
xstatus.cbSize = sizeof(CUSTOM_STATUS);
xstatus.flags = CSSF_MASK_NAME | CSSF_DEFAULT_NAME | CSSF_UNICODE;
xstatus.ptszName = szDefaultName;
xstatus.wParam = &j;
CallProtoService(ProtoList.protoInfo[i].szProto, PS_GETCUSTOMSTATUSEX, 0, (LPARAM)&xstatus);
tvis.item.pszText = TranslateW(szDefaultName);
}
tvis.item.lParam = (LPARAM)j;
tvis.item.iImage = tvis.item.iSelectedImage = j ? ImageList_AddIcon(hImageList, hIconAux = (HICON)CallProtoService(ProtoList.protoInfo[i].szProto, PS_GETCUSTOMSTATUSICON, (WPARAM)j, 0)) : 0;
if (hIconAux) DestroyIcon(hIconAux);
TreeView_InsertItem(hwndTree, &tvis);
}
}
tvi.mask = TVIF_HANDLE | TVIF_PARAM;
for (hSectionItem = TreeView_GetRoot(hwndTree); hSectionItem; hSectionItem = TreeView_GetNextSibling(hwndTree, hSectionItem)) {
tvi.hItem = hSectionItem;
TreeView_GetItem(hwndTree, &tvi);
unsigned int i = (unsigned int)tvi.lParam;
TreeView_SetItemState(hwndTree, hSectionItem, INDEXTOSTATEIMAGEMASK(0), TVIS_STATEIMAGEMASK);
for (hItem = TreeView_GetChild(hwndTree, hSectionItem); hItem; hItem = TreeView_GetNextSibling(hwndTree, hItem)) {
tvi.hItem = hItem;
TreeView_GetItem(hwndTree, &tvi);
j = (unsigned int)tvi.lParam;
TreeView_SetItemState(hwndTree, hItem, INDEXTOSTATEIMAGEMASK(XstatusListAux[i].enabled[j] ? 2 : 1), TVIS_STATEIMAGEMASK);
}
}
ShowWindow(hwndTree, SW_SHOW);
TreeView_SetItemState(hwndTree, 0, TVIS_SELECTED, TVIS_SELECTED);
}
return TRUE;
case WM_DESTROY:
{
// Destroy tree view imagelist since it does not get destroyed automatically (see msdn docs)
HIMAGELIST hImageList = TreeView_GetImageList(GetDlgItem(hwndDlg, IDC_TREE_XSTATUS), TVSIL_STATE);
if (hImageList) {
TreeView_SetImageList(GetDlgItem(hwndDlg, IDC_TREE_XSTATUS), NULL, TVSIL_STATE);
ImageList_Destroy(hImageList);
}
hImageList = TreeView_GetImageList(GetDlgItem(hwndDlg, IDC_TREE_XSTATUS), TVSIL_NORMAL);
if (hImageList) {
TreeView_SetImageList(GetDlgItem(hwndDlg, IDC_TREE_XSTATUS), NULL, TVSIL_NORMAL);
ImageList_Destroy(hImageList);
}
}
return TRUE;
case WM_SYSCOMMAND:
if (wParam == SC_CLOSE)
EndDialog(hwndDlg, IDC_CANCELXST);
break;
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDC_OKXST:
{
unsigned int i, j;
HTREEITEM hSectionItem, hItem;
TVITEM tvi = { 0 };
HWND hwndTree = GetDlgItem(hwndDlg, IDC_TREE_XSTATUS);
tvi.mask = TVIF_HANDLE | TVIF_PARAM;
for (hSectionItem = TreeView_GetRoot(hwndTree); hSectionItem; hSectionItem = TreeView_GetNextSibling(hwndTree, hSectionItem)) {
tvi.hItem = hSectionItem;
TreeView_GetItem(hwndTree, &tvi);
i = (unsigned int)tvi.lParam;
for (hItem = TreeView_GetChild(hwndTree, hSectionItem); hItem; hItem = TreeView_GetNextSibling(hwndTree, hItem)) {
tvi.hItem = hItem;
TreeView_GetItem(hwndTree, &tvi);
j = (unsigned int)tvi.lParam;
XstatusListAux[i].enabled[j] = (TreeView_GetItemState(hwndTree, hItem, TVIS_STATEIMAGEMASK) & INDEXTOSTATEIMAGEMASK(2));
}
}
}
__fallthrough;
case IDC_CANCELXST:
EndDialog(hwndDlg, LOWORD(wParam));
return TRUE;
}
break;
}
return FALSE;
}
static INT_PTR CALLBACK DlgProcEventLeds(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM)
{
switch (msg) {
case WM_INITDIALOG:
TranslateDialogDefault(hwndDlg);
CheckDlgButton(hwndDlg, IDC_MSGLEDNUM, trillianLedsMsg & 2 ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_MSGLEDCAPS, trillianLedsMsg & 4 ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_MSGLEDSCROLL, trillianLedsMsg & 1 ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_FILELEDNUM, trillianLedsFile & 2 ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_FILELEDCAPS, trillianLedsFile & 4 ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_FILELEDSCROLL, trillianLedsFile & 1 ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_URLLEDNUM, trillianLedsURL & 2 ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_URLLEDCAPS, trillianLedsURL & 4 ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_URLLEDSCROLL, trillianLedsURL & 1 ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_OTHERLEDNUM, trillianLedsOther & 2 ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_OTHERLEDCAPS, trillianLedsOther & 4 ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_OTHERLEDSCROLL, trillianLedsOther & 1 ? BST_CHECKED : BST_UNCHECKED);
return TRUE;
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDC_OK:
trillianLedsMsg = 0;
if (IsDlgButtonChecked(hwndDlg, IDC_MSGLEDNUM) == BST_CHECKED)
trillianLedsMsg |= 2;
if (IsDlgButtonChecked(hwndDlg, IDC_MSGLEDCAPS) == BST_CHECKED)
trillianLedsMsg |= 4;
if (IsDlgButtonChecked(hwndDlg, IDC_MSGLEDSCROLL) == BST_CHECKED)
trillianLedsMsg |= 1;
trillianLedsFile = 0;
if (IsDlgButtonChecked(hwndDlg, IDC_FILELEDNUM) == BST_CHECKED)
trillianLedsFile |= 2;
if (IsDlgButtonChecked(hwndDlg, IDC_FILELEDCAPS) == BST_CHECKED)
trillianLedsFile |= 4;
if (IsDlgButtonChecked(hwndDlg, IDC_FILELEDSCROLL) == BST_CHECKED)
trillianLedsFile |= 1;
trillianLedsURL = 0;
if (IsDlgButtonChecked(hwndDlg, IDC_URLLEDNUM) == BST_CHECKED)
trillianLedsURL |= 2;
if (IsDlgButtonChecked(hwndDlg, IDC_URLLEDCAPS) == BST_CHECKED)
trillianLedsURL |= 4;
if (IsDlgButtonChecked(hwndDlg, IDC_URLLEDSCROLL) == BST_CHECKED)
trillianLedsURL |= 1;
trillianLedsOther = 0;
if (IsDlgButtonChecked(hwndDlg, IDC_OTHERLEDNUM) == BST_CHECKED)
trillianLedsOther |= 2;
if (IsDlgButtonChecked(hwndDlg, IDC_OTHERLEDCAPS) == BST_CHECKED)
trillianLedsOther |= 4;
if (IsDlgButtonChecked(hwndDlg, IDC_OTHERLEDSCROLL) == BST_CHECKED)
trillianLedsOther |= 1;
// fall through
case IDC_CANCEL:
EndDialog(hwndDlg, LOWORD(wParam));
break;
}
break;
}
return FALSE;
}
static INT_PTR CALLBACK DlgProcProtoOptions(HWND hwndDlg, UINT msg, WPARAM, LPARAM lParam)
{
static BOOL initDlg = FALSE;
switch (msg) {
case WM_INITDIALOG:
initDlg = TRUE;
TranslateDialogDefault(hwndDlg);
// proto list
{
LVCOLUMN lvCol;
LVITEM lvItem;
HWND hList = GetDlgItem(hwndDlg, IDC_PROTOCOLLIST);
// create columns
ListView_SetExtendedListViewStyleEx(hList, LVS_EX_CHECKBOXES, LVS_EX_CHECKBOXES);
memset(&lvCol, 0, sizeof(lvCol));
lvCol.mask = LVCF_WIDTH | LVCF_TEXT;
lvCol.pszText = TranslateT("Protocol");
lvCol.cx = 118;
ListView_InsertColumn(hList, 0, &lvCol);
// fill
memset(&lvItem, 0, sizeof(lvItem));
lvItem.mask = LVIF_TEXT | LVIF_PARAM;
lvItem.iItem = 0;
lvItem.iSubItem = 0;
for (int i = 0; i < ProtoList.protoCount; i++) {
int count; PROTOACCOUNT **protos;
Proto_EnumAccounts(&count, &protos);
if (ProtoList.protoInfo[i].visible) {
lvItem.lParam = (LPARAM)ProtoList.protoInfo[i].szProto;
lvItem.pszText = protos[i]->tszAccountName;
ListView_InsertItem(hList, &lvItem);
ListView_SetCheckState(hList, lvItem.iItem, ProtoList.protoInfo[i].enabled);
lvItem.iItem++;
}
}
}
initDlg = FALSE;
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:
// enabled protos
{
LVITEM lvItem;
HWND hList = GetDlgItem(hwndDlg, IDC_PROTOCOLLIST);
memset(&lvItem, 0, sizeof(lvItem));
lvItem.mask = LVIF_PARAM;
lvItem.iSubItem = 0;
for (int i = 0; i < ListView_GetItemCount(hList); i++) {
lvItem.iItem = i;
ListView_GetItem(hList, &lvItem);
g_plugin.setByte((char *)lvItem.lParam, (uint8_t)ListView_GetCheckState(hList, lvItem.iItem));
}
}
LoadSettings();
return TRUE;
} // switch code - 0
break;
case IDC_PROTOCOLLIST:
switch (((NMHDR *)lParam)->code) {
case LVN_ITEMCHANGED:
{
NMLISTVIEW *nmlv = (NMLISTVIEW *)lParam;
if (!initDlg && ((nmlv->uNewState ^ nmlv->uOldState) & LVIS_STATEIMAGEMASK))
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
}
break;
} // switch code - IDC_PROTOCOLLIST
break;
} //switch idFrom
}
break; //End WM_NOTIFY
default:
break;
}
return FALSE;
}
static INT_PTR CALLBACK DlgProcBasicOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
static BOOL initDlg = FALSE;
switch (msg) {
case WM_INITDIALOG:
initDlg = TRUE;
TranslateDialogDefault(hwndDlg);
createProcessListAux();
createXstatusListAux();
CheckDlgButton(hwndDlg, IDC_ONMESSAGE, bFlashOnMsg ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_ONFILE, bFlashOnFile ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_GCMSG, bFlashOnGC ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_ONOTHER, bFlashOnOther ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_FSCREEN, bFullScreenMode ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_SSAVER, bScreenSaverRunning ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_LOCKED, bWorkstationLocked ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_PGMS, bProcessesAreRunning ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_ACTIVE, bWorkstationActive ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_IFOPEN, bFlashIfMsgOpen ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_IFNOTTOP, bFlashIfMsgWinNotTop ? BST_CHECKED : BST_UNCHECKED);
if (!bFlashIfMsgOpen)
EnableWindow(GetDlgItem(hwndDlg, IDC_IFNOTTOP), FALSE);
CheckDlgButton(hwndDlg, IDC_IFOLDER, bFlashIfMsgOlder ? BST_CHECKED : BST_UNCHECKED);
SendDlgItemMessage(hwndDlg, IDC_OLDERSPIN, UDM_SETBUDDY, (WPARAM)GetDlgItem(hwndDlg, IDC_SOLDER), 0);
SendDlgItemMessage(hwndDlg, IDC_OLDERSPIN, UDM_SETRANGE32, 1, MAKELONG(UD_MAXVAL, 0));
SendDlgItemMessage(hwndDlg, IDC_OLDERSPIN, UDM_SETPOS, 0, MAKELONG(wSecondsOlder, 0));
if (!bFlashIfMsgOlder) {
EnableWindow(GetDlgItem(hwndDlg, IDC_SOLDER), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_OLDERSPIN), FALSE);
}
CheckDlgButton(hwndDlg, IDC_UNTILBLK, bFlashUntil & UNTIL_NBLINKS ? BST_CHECKED : BST_UNCHECKED);
SendDlgItemMessage(hwndDlg, IDC_BLINKSPIN, UDM_SETBUDDY, (WPARAM)GetDlgItem(hwndDlg, IDC_SBLINK), 0);
SendDlgItemMessage(hwndDlg, IDC_BLINKSPIN, UDM_SETRANGE32, 1, MAKELONG(UD_MAXVAL, 0));
SendDlgItemMessage(hwndDlg, IDC_BLINKSPIN, UDM_SETPOS, 0, MAKELONG(wBlinksNumber, 0));
if (!(bFlashUntil & UNTIL_NBLINKS)) {
EnableWindow(GetDlgItem(hwndDlg, IDC_SBLINK), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_BLINKSPIN), FALSE);
}
CheckDlgButton(hwndDlg, IDC_UNTILATTENDED, bFlashUntil & UNTIL_REATTENDED ? BST_CHECKED : BST_UNCHECKED);
for (int i = 0; i < 2; i++) {
int index = SendDlgItemMessage(hwndDlg, IDC_MIRORWIN, CB_INSERTSTRING, (WPARAM)-1, (LPARAM)AttendedName[i]);
if (index != CB_ERR && index != CB_ERRSPACE)
SendDlgItemMessage(hwndDlg, IDC_MIRORWIN, CB_SETITEMDATA, (WPARAM)index, (LPARAM)i);
}
SendDlgItemMessage(hwndDlg, IDC_MIRORWIN, CB_SETCURSEL, (WPARAM)bMirandaOrWindows, 0);
if (!(bFlashUntil & UNTIL_REATTENDED))
EnableWindow(GetDlgItem(hwndDlg, IDC_MIRORWIN), FALSE);
CheckDlgButton(hwndDlg, IDC_UNTILOPEN, bFlashUntil & UNTIL_EVENTSOPEN ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_UNTILCOND, bFlashUntil & UNTIL_CONDITIONS ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_ONLINE, wStatusMap & MAP_ONLINE ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_AWAY, wStatusMap & MAP_AWAY ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_NA, wStatusMap & MAP_NA ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_OCCUPIED, wStatusMap & MAP_OCCUPIED ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_DND, wStatusMap & MAP_DND ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_FREECHAT, wStatusMap & MAP_FREECHAT ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_INVISIBLE, wStatusMap & MAP_INVISIBLE ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_OFFLINE, wStatusMap & MAP_OFFLINE ? BST_CHECKED : BST_UNCHECKED);
SendDlgItemMessage(hwndDlg, IDC_REMCHECK, UDM_SETBUDDY, (WPARAM)GetDlgItem(hwndDlg, IDC_SREMCHECK), 0);
SendDlgItemMessage(hwndDlg, IDC_REMCHECK, UDM_SETRANGE32, 0, MAKELONG(UD_MAXVAL, 0));
SendDlgItemMessage(hwndDlg, IDC_REMCHECK, UDM_SETPOS, 0, MAKELONG(wReminderCheck, 0));
initDlg = FALSE;
return TRUE;
case WM_VSCROLL:
case WM_HSCROLL:
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
case WM_DESTROY:
destroyProcessListAux();
destroyXstatusListAux();
break;
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDC_ONMESSAGE:
case IDC_GCMSG:
case IDC_ONFILE:
case IDC_ONOTHER:
case IDC_IFOPEN:
case IDC_IFNOTTOP:
case IDC_IFOLDER:
case IDC_UNTILBLK:
case IDC_UNTILATTENDED:
case IDC_UNTILOPEN:
case IDC_UNTILCOND:
case IDC_FSCREEN:
case IDC_SSAVER:
case IDC_LOCKED:
case IDC_PGMS:
case IDC_ACTIVE:
case IDC_ONLINE:
case IDC_AWAY:
case IDC_NA:
case IDC_OCCUPIED:
case IDC_DND:
case IDC_FREECHAT:
case IDC_INVISIBLE:
case IDC_OFFLINE:
EnableWindow(GetDlgItem(hwndDlg, IDC_IFNOTTOP), IsDlgButtonChecked(hwndDlg, IDC_IFOPEN) == BST_CHECKED);
EnableWindow(GetDlgItem(hwndDlg, IDC_SOLDER), IsDlgButtonChecked(hwndDlg, IDC_IFOLDER) == BST_CHECKED);
EnableWindow(GetDlgItem(hwndDlg, IDC_OLDERSPIN), IsDlgButtonChecked(hwndDlg, IDC_IFOLDER) == BST_CHECKED);
EnableWindow(GetDlgItem(hwndDlg, IDC_SBLINK), IsDlgButtonChecked(hwndDlg, IDC_UNTILBLK) == BST_CHECKED);
EnableWindow(GetDlgItem(hwndDlg, IDC_BLINKSPIN), IsDlgButtonChecked(hwndDlg, IDC_UNTILBLK) == BST_CHECKED);
EnableWindow(GetDlgItem(hwndDlg, IDC_MIRORWIN), IsDlgButtonChecked(hwndDlg, IDC_UNTILATTENDED) == BST_CHECKED);
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
return TRUE;
case IDC_SOLDER:
if (HIWORD(wParam) == EN_CHANGE && !initDlg) {
BOOL translated;
int val = GetDlgItemInt(hwndDlg, IDC_SOLDER, &translated, FALSE);
if (translated && val < 1)
SendDlgItemMessage(hwndDlg, IDC_OLDERSPIN, UDM_SETPOS, 0, MAKELONG(val, 0));
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
}
return TRUE;
case IDC_SBLINK:
if (HIWORD(wParam) == EN_CHANGE && !initDlg) {
BOOL translated;
int val = GetDlgItemInt(hwndDlg, IDC_SBLINK, &translated, FALSE);
if (translated && val < 1)
SendDlgItemMessage(hwndDlg, IDC_BLINKSPIN, UDM_SETPOS, 0, MAKELONG(val, 0));
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
}
return TRUE;
case IDC_ASSIGNPGMS:
if (DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_PROCESSES), hwndDlg, DlgProcProcesses, 0) == IDC_OKPGM)
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
return TRUE;
case IDC_SELECTXSTATUS:
if (DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_XSTATUSES), hwndDlg, DlgProcXstatusList, 0) == IDC_OKXST)
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
return TRUE;
case IDC_SREMCHECK:
if (HIWORD(wParam) == EN_CHANGE && !initDlg)
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
return TRUE;
case IDC_MIRORWIN:
if (HIWORD(wParam) == CBN_SELCHANGE)
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
return TRUE;
}
break;
case WM_NOTIFY:
{
uint8_t untilMap = 0;
uint16_t statusMap = 0;
//Here we have pressed either the OK or the APPLY button.
switch (((LPNMHDR)lParam)->idFrom) {
case 0:
switch (((LPNMHDR)lParam)->code) {
case PSN_APPLY:
g_plugin.setByte("onmsg", (uint8_t)(IsDlgButtonChecked(hwndDlg, IDC_ONMESSAGE) == BST_CHECKED ? 1 : 0));
g_plugin.setByte("ongcmsg", (uint8_t)(IsDlgButtonChecked(hwndDlg, IDC_GCMSG) == BST_CHECKED ? 1 : 0));
g_plugin.setByte("onfile", (uint8_t)(IsDlgButtonChecked(hwndDlg, IDC_ONFILE) == BST_CHECKED ? 1 : 0));
g_plugin.setByte("onother", (uint8_t)(IsDlgButtonChecked(hwndDlg, IDC_ONOTHER) == BST_CHECKED ? 1 : 0));
g_plugin.setByte("fscreenmode", (uint8_t)(IsDlgButtonChecked(hwndDlg, IDC_FSCREEN) == BST_CHECKED ? 1 : 0));
g_plugin.setByte("ssaverrunning", (uint8_t)(IsDlgButtonChecked(hwndDlg, IDC_SSAVER) == BST_CHECKED ? 1 : 0));
g_plugin.setByte("wstationlocked", (uint8_t)(IsDlgButtonChecked(hwndDlg, IDC_LOCKED) == BST_CHECKED ? 1 : 0));
g_plugin.setByte("procsrunning", (uint8_t)(IsDlgButtonChecked(hwndDlg, IDC_PGMS) == BST_CHECKED ? 1 : 0));
g_plugin.setByte("wstationactive", (uint8_t)(IsDlgButtonChecked(hwndDlg, IDC_ACTIVE) == BST_CHECKED ? 1 : 0));
g_plugin.setByte("ifmsgopen", (uint8_t)(IsDlgButtonChecked(hwndDlg, IDC_IFOPEN) == BST_CHECKED ? 1 : 0));
g_plugin.setByte("ifmsgnottop", (uint8_t)(IsDlgButtonChecked(hwndDlg, IDC_IFNOTTOP) == BST_CHECKED ? 1 : 0));
g_plugin.setByte("ifmsgolder", (uint8_t)(IsDlgButtonChecked(hwndDlg, IDC_IFOLDER) == BST_CHECKED ? 1 : 0));
g_plugin.setWord("secsolder", (uint16_t)SendDlgItemMessage(hwndDlg, IDC_OLDERSPIN, UDM_GETPOS, 0, 0));
if (IsDlgButtonChecked(hwndDlg, IDC_UNTILBLK) == BST_CHECKED)
untilMap |= UNTIL_NBLINKS;
if (IsDlgButtonChecked(hwndDlg, IDC_UNTILATTENDED) == BST_CHECKED)
untilMap |= UNTIL_REATTENDED;
if (IsDlgButtonChecked(hwndDlg, IDC_UNTILOPEN) == BST_CHECKED)
untilMap |= UNTIL_EVENTSOPEN;
if (IsDlgButtonChecked(hwndDlg, IDC_UNTILCOND) == BST_CHECKED)
untilMap |= UNTIL_CONDITIONS;
g_plugin.setByte("funtil", untilMap);
g_plugin.setWord("nblinks", (uint16_t)SendDlgItemMessage(hwndDlg, IDC_BLINKSPIN, UDM_GETPOS, 0, 0));
g_plugin.setByte("mirorwin", (uint8_t)SendDlgItemMessage(hwndDlg, IDC_MIRORWIN, CB_GETITEMDATA, (WPARAM)SendDlgItemMessage(hwndDlg, IDC_MIRORWIN, CB_GETCURSEL, 0, 0), 0));
if (IsDlgButtonChecked(hwndDlg, IDC_ONLINE) == BST_CHECKED)
statusMap |= MAP_ONLINE;
if (IsDlgButtonChecked(hwndDlg, IDC_AWAY) == BST_CHECKED)
statusMap |= MAP_AWAY;
if (IsDlgButtonChecked(hwndDlg, IDC_NA) == BST_CHECKED)
statusMap |= MAP_NA;
if (IsDlgButtonChecked(hwndDlg, IDC_OCCUPIED) == BST_CHECKED)
statusMap |= MAP_OCCUPIED;
if (IsDlgButtonChecked(hwndDlg, IDC_DND) == BST_CHECKED)
statusMap |= MAP_DND;
if (IsDlgButtonChecked(hwndDlg, IDC_FREECHAT) == BST_CHECKED)
statusMap |= MAP_FREECHAT;
if (IsDlgButtonChecked(hwndDlg, IDC_INVISIBLE) == BST_CHECKED)
statusMap |= MAP_INVISIBLE;
if (IsDlgButtonChecked(hwndDlg, IDC_OFFLINE) == BST_CHECKED)
statusMap |= MAP_OFFLINE;
g_plugin.setWord("status", statusMap);
g_plugin.setWord("remcheck", (uint16_t)SendDlgItemMessage(hwndDlg, IDC_REMCHECK, UDM_GETPOS, 0, 0));
int i = 0;
for (int j = 0; j < ProcessListAux.count; j++)
if (ProcessListAux.szFileName[j])
g_plugin.setWString(fmtDBSettingName("process%d", i++), ProcessListAux.szFileName[j]);
g_plugin.setWord("processcount", (uint16_t)i);
while (!g_plugin.delSetting(fmtDBSettingName("process%d", i++)));
if (XstatusListAux)
for (i = 0; i < ProtoList.protoCount; i++)
for (int j = 0; j < (int)XstatusListAux[i].count; j++)
g_plugin.setByte(fmtDBSettingName("%sxstatus%d", ProtoList.protoInfo[i].szProto, j), (uint8_t)XstatusListAux[i].enabled[j]);
LoadSettings();
return TRUE;
} // switch code
break;
} //switch idFrom
}
break; //End WM_NOTIFY
default:
break;
}
return FALSE;
}
static INT_PTR CALLBACK DlgProcEffectOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
static BOOL initDlg = FALSE;
switch (msg) {
case WM_INITDIALOG:
initDlg = TRUE;
TranslateDialogDefault(hwndDlg);
trillianLedsMsg = bTrillianLedsMsg;
trillianLedsURL = bTrillianLedsURL;
trillianLedsFile = bTrillianLedsFile;
trillianLedsOther = bTrillianLedsOther;
CheckDlgButton(hwndDlg, IDC_NUM, bFlashLed[0] ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_CAPS, bFlashLed[1] ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_SCROLL, bFlashLed[2] ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_SAMETIME, bFlashEffect == FLASH_SAMETIME ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_INTURN, bFlashEffect == FLASH_INTURN ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_INSEQUENCE, bFlashEffect == FLASH_INSEQUENCE ? BST_CHECKED : BST_UNCHECKED);
for (int i = 0; i < 3; i++) {
int index = SendDlgItemMessage(hwndDlg, IDC_SEQORDER, CB_INSERTSTRING, -1, (LPARAM)TranslateW(OrderName[i]));
if (index != CB_ERR && index != CB_ERRSPACE)
SendDlgItemMessage(hwndDlg, IDC_SEQORDER, CB_SETITEMDATA, (WPARAM)index, (LPARAM)i);
}
SendDlgItemMessage(hwndDlg, IDC_SEQORDER, CB_SETCURSEL, (WPARAM)bSequenceOrder, 0);
if (bFlashEffect != FLASH_INSEQUENCE)
EnableWindow(GetDlgItem(hwndDlg, IDC_SEQORDER), FALSE);
CheckDlgButton(hwndDlg, IDC_CUSTOM, bFlashEffect == FLASH_CUSTOM ? BST_CHECKED : BST_UNCHECKED);
wchar_t *szTheme;
for (int i = 0; szTheme = g_plugin.getWStringA(fmtDBSettingName("theme%d", i)); i++) {
int index = SendDlgItemMessage(hwndDlg, IDC_SCUSTOM, CB_INSERTSTRING, (WPARAM)-1, (LPARAM)szTheme);
mir_free(szTheme);
if (index != CB_ERR && index != CB_ERRSPACE)
SendDlgItemMessage(hwndDlg, IDC_SCUSTOM, CB_SETITEMDATA, (WPARAM)index, (LPARAM)i);
}
SendDlgItemMessage(hwndDlg, IDC_SCUSTOM, CB_SETCURSEL, (WPARAM)wCustomTheme, 0);
if (bFlashEffect != FLASH_CUSTOM)
EnableWindow(GetDlgItem(hwndDlg, IDC_SCUSTOM), FALSE);
CheckDlgButton(hwndDlg, IDC_TRILLIAN, bFlashEffect == FLASH_TRILLIAN ? BST_CHECKED : BST_UNCHECKED);
if (bFlashEffect != FLASH_TRILLIAN)
EnableWindow(GetDlgItem(hwndDlg, IDC_ASSIGNLEDS), FALSE);
SendDlgItemMessage(hwndDlg, IDC_DELAYSPIN, UDM_SETBUDDY, (WPARAM)GetDlgItem(hwndDlg, IDC_SDELAY), 0);
SendDlgItemMessage(hwndDlg, IDC_DELAYSPIN, UDM_SETRANGE32, 0, MAKELONG(UD_MAXVAL, 0));
SendDlgItemMessage(hwndDlg, IDC_DELAYSPIN, UDM_SETPOS, 0, MAKELONG(wStartDelay, 0));
SendDlgItemMessage(hwndDlg, IDC_SPEED, TBM_SETRANGE, FALSE, MAKELONG(0, 5));
SendDlgItemMessage(hwndDlg, IDC_SPEED, TBM_SETPOS, TRUE, bFlashSpeed);
CheckDlgButton(hwndDlg, IDC_KEYPRESSES, bEmulateKeypresses ? BST_CHECKED : BST_UNCHECKED);
initDlg = FALSE;
return TRUE;
case WM_VSCROLL:
case WM_HSCROLL:
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
case WM_DESTROY:
previewFlashing(FALSE);
break;
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDC_NUM:
case IDC_CAPS:
case IDC_SCROLL:
case IDC_SAMETIME:
case IDC_INTURN:
case IDC_INSEQUENCE:
case IDC_CUSTOM:
case IDC_TRILLIAN:
case IDC_SPEED:
case IDC_KEYPRESSES:
EnableWindow(GetDlgItem(hwndDlg, IDC_SEQORDER), IsDlgButtonChecked(hwndDlg, IDC_INSEQUENCE) == BST_CHECKED);
EnableWindow(GetDlgItem(hwndDlg, IDC_SCUSTOM), IsDlgButtonChecked(hwndDlg, IDC_CUSTOM) == BST_CHECKED);
EnableWindow(GetDlgItem(hwndDlg, IDC_ASSIGNLEDS), IsDlgButtonChecked(hwndDlg, IDC_TRILLIAN) == BST_CHECKED);
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
return TRUE;
case IDC_ASSIGNLEDS:
if (DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_EVENTLEDS), hwndDlg, DlgProcEventLeds, 0) == IDC_OK)
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
return TRUE;
case IDC_SDELAY:
if (HIWORD(wParam) == EN_CHANGE && !initDlg)
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
return TRUE;
case IDC_PREVIEW:
previewFlashing(IsDlgButtonChecked(hwndDlg, IDC_PREVIEW) == BST_CHECKED);
return TRUE;
case IDC_SEQORDER:
case IDC_SCUSTOM:
if (HIWORD(wParam) == CBN_SELCHANGE)
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
return TRUE;
}
break;
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:
g_plugin.setByte("fnum", (uint8_t)(IsDlgButtonChecked(hwndDlg, IDC_NUM) == BST_CHECKED ? 1 : 0));
g_plugin.setByte("fcaps", (uint8_t)(IsDlgButtonChecked(hwndDlg, IDC_CAPS) == BST_CHECKED ? 1 : 0));
g_plugin.setByte("fscroll", (uint8_t)(IsDlgButtonChecked(hwndDlg, IDC_SCROLL) == BST_CHECKED ? 1 : 0));
if (IsDlgButtonChecked(hwndDlg, IDC_INTURN) == BST_CHECKED)
g_plugin.setByte("feffect", FLASH_INTURN);
else if (IsDlgButtonChecked(hwndDlg, IDC_INSEQUENCE) == BST_CHECKED)
g_plugin.setByte("feffect", FLASH_INSEQUENCE);
else if (IsDlgButtonChecked(hwndDlg, IDC_CUSTOM) == BST_CHECKED)
g_plugin.setByte("feffect", FLASH_CUSTOM);
else if (IsDlgButtonChecked(hwndDlg, IDC_TRILLIAN) == BST_CHECKED)
g_plugin.setByte("feffect", FLASH_TRILLIAN);
else
g_plugin.setByte("feffect", FLASH_SAMETIME);
g_plugin.setByte("order", (uint8_t)SendDlgItemMessage(hwndDlg, IDC_SEQORDER, CB_GETITEMDATA, (WPARAM)SendDlgItemMessage(hwndDlg, IDC_SEQORDER, CB_GETCURSEL, 0, 0), 0));
g_plugin.setWord("custom", (uint16_t)SendDlgItemMessage(hwndDlg, IDC_SCUSTOM, CB_GETITEMDATA, (WPARAM)SendDlgItemMessage(hwndDlg, IDC_SCUSTOM, CB_GETCURSEL, 0, 0), 0));
g_plugin.setByte("ledsmsg", trillianLedsMsg);
g_plugin.setByte("ledsfile", trillianLedsFile);
g_plugin.setByte("ledsurl", trillianLedsURL);
g_plugin.setByte("ledsother", trillianLedsOther);
g_plugin.setWord("sdelay", (uint16_t)SendDlgItemMessage(hwndDlg, IDC_DELAYSPIN, UDM_GETPOS, 0, 0));
g_plugin.setByte("speed", (uint8_t)SendDlgItemMessage(hwndDlg, IDC_SPEED, TBM_GETPOS, 0, 0));
g_plugin.setByte("keypresses", (uint8_t)(IsDlgButtonChecked(hwndDlg, IDC_KEYPRESSES) == BST_CHECKED ? 1 : 0));
LoadSettings();
return TRUE;
} // switch code
break;
} //switch idFrom
}
break; //End WM_NOTIFY
default:
break;
}
return FALSE;
}
static INT_PTR CALLBACK DlgProcThemeOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
static BOOL initDlg = FALSE;
switch (msg) {
case WM_INITDIALOG:
initDlg = TRUE;
TranslateDialogDefault(hwndDlg);
SendDlgItemMessage(hwndDlg, IDC_THEME, EM_LIMITTEXT, MAX_PATH, 0);
SendDlgItemMessage(hwndDlg, IDC_CUSTOMSTRING, EM_LIMITTEXT, MAX_PATH, 0);
wchar_t *szTheme;
for (int i = 0; szTheme = g_plugin.getWStringA(fmtDBSettingName("theme%d", i)); i++) {
int index = SendDlgItemMessage(hwndDlg, IDC_THEME, CB_INSERTSTRING, (WPARAM)-1, (LPARAM)szTheme);
mir_free(szTheme);
if (index != CB_ERR && index != CB_ERRSPACE) {
wchar_t *str = g_plugin.getWStringA(fmtDBSettingName("custom%d", i));
if (str)
SendDlgItemMessage(hwndDlg, IDC_THEME, CB_SETITEMDATA, (WPARAM)index, (LPARAM)str);
}
}
EnableWindow(GetDlgItem(hwndDlg, IDC_ADD), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_UPDATE), FALSE);
if (SendDlgItemMessage(hwndDlg, IDC_THEME, CB_GETCOUNT, 0, 0) == 0)
EnableWindow(GetDlgItem(hwndDlg, IDC_DELETE), FALSE);
else {
SendDlgItemMessage(hwndDlg, IDC_THEME, CB_SETCURSEL, (WPARAM)wCustomTheme, 0);
wchar_t *str = (wchar_t *)SendDlgItemMessage(hwndDlg, IDC_THEME, CB_GETITEMDATA, (WPARAM)wCustomTheme, 0);
if (str)
SetDlgItemText(hwndDlg, IDC_CUSTOMSTRING, str);
}
CheckDlgButton(hwndDlg, IDC_OVERRIDE, bOverride ? BST_CHECKED : BST_UNCHECKED);
initDlg = FALSE;
return TRUE;
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDC_THEME:
switch (HIWORD(wParam)) {
case CBN_SELENDOK:
case CBN_SELCHANGE:
{
wchar_t *str = (wchar_t *)SendMessage((HWND)lParam, CB_GETITEMDATA, (WPARAM)SendMessage((HWND)lParam, CB_GETCURSEL, 0, 0), 0);
if (str)
SetDlgItemText(hwndDlg, IDC_CUSTOMSTRING, str);
else
SetDlgItemText(hwndDlg, IDC_CUSTOMSTRING, L"");
EnableWindow(GetDlgItem(hwndDlg, IDC_ADD), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_UPDATE), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_DELETE), TRUE);
}
break;
case CBN_EDITCHANGE:
wchar_t theme[MAX_PATH + 1];
GetDlgItemText(hwndDlg, IDC_THEME, theme, _countof(theme));
int item = SendMessage((HWND)lParam, CB_FINDSTRINGEXACT, -1, (LPARAM)theme);
if (item == CB_ERR) {
//new theme
SetDlgItemText(hwndDlg, IDC_CUSTOMSTRING, L"");
EnableWindow(GetDlgItem(hwndDlg, IDC_ADD), TRUE);
EnableWindow(GetDlgItem(hwndDlg, IDC_DELETE), FALSE);
}
else {
wchar_t *str = (wchar_t *)SendMessage((HWND)lParam, CB_GETITEMDATA, (WPARAM)item, 0);
if (str)
SetDlgItemText(hwndDlg, IDC_CUSTOMSTRING, str);
else
SetDlgItemText(hwndDlg, IDC_CUSTOMSTRING, L"");
EnableWindow(GetDlgItem(hwndDlg, IDC_ADD), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_DELETE), TRUE);
}
EnableWindow(GetDlgItem(hwndDlg, IDC_UPDATE), FALSE);
break;
}
return TRUE;
case IDC_CUSTOMSTRING:
if (HIWORD(wParam) == EN_CHANGE) {
wchar_t theme[MAX_PATH + 1], customAux[MAX_PATH + 1];
GetDlgItemText(hwndDlg, IDC_THEME, theme, _countof(theme));
int item = SendDlgItemMessage(hwndDlg, IDC_THEME, CB_FINDSTRINGEXACT, -1, (LPARAM)theme);
if (item == CB_ERR)
return TRUE;
wchar_t *str = (wchar_t *)SendDlgItemMessage(hwndDlg, IDC_THEME, CB_GETITEMDATA, (WPARAM)item, 0);
if (str) {
GetDlgItemText(hwndDlg, IDC_CUSTOMSTRING, customAux, _countof(customAux));
if (mir_wstrcmp(str, customAux))
EnableWindow(GetDlgItem(hwndDlg, IDC_UPDATE), TRUE);
else
EnableWindow(GetDlgItem(hwndDlg, IDC_UPDATE), FALSE);
}
}
return TRUE;
case IDC_TEST:
{
wchar_t custom[MAX_PATH + 1];
GetDlgItemText(hwndDlg, IDC_CUSTOMSTRING, custom, _countof(custom));
SetDlgItemText(hwndDlg, IDC_CUSTOMSTRING, normalizeCustomString(custom));
testSequence(custom);
}
return TRUE;
case IDC_ADD:
{
wchar_t theme[MAX_PATH + 1];
GetDlgItemText(hwndDlg, IDC_THEME, theme, _countof(theme));
if (!theme[0])
return TRUE;
int item = SendDlgItemMessage(hwndDlg, IDC_THEME, CB_ADDSTRING, 0, (LPARAM)theme);
wchar_t *str = (wchar_t *)mir_alloc((MAX_PATH + 1) * sizeof(wchar_t));
if (str) {
GetDlgItemText(hwndDlg, IDC_CUSTOMSTRING, str, MAX_PATH);
SetDlgItemText(hwndDlg, IDC_CUSTOMSTRING, normalizeCustomString(str));
}
SendDlgItemMessage(hwndDlg, IDC_THEME, CB_SETITEMDATA, (WPARAM)item, (LPARAM)str);
EnableWindow(GetDlgItem(hwndDlg, IDC_ADD), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_UPDATE), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_DELETE), TRUE);
}
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
return TRUE;
case IDC_UPDATE:
{
wchar_t theme[MAX_PATH + 1];
GetDlgItemText(hwndDlg, IDC_THEME, theme, _countof(theme));
int item = SendDlgItemMessage(hwndDlg, IDC_THEME, CB_FINDSTRINGEXACT, -1, (LPARAM)theme);
wchar_t *str = (wchar_t *)SendDlgItemMessage(hwndDlg, IDC_THEME, CB_GETITEMDATA, (WPARAM)item, 0);
if (str) {
GetDlgItemText(hwndDlg, IDC_CUSTOMSTRING, str, MAX_PATH);
SetDlgItemText(hwndDlg, IDC_CUSTOMSTRING, normalizeCustomString(str));
}
EnableWindow(GetDlgItem(hwndDlg, IDC_UPDATE), FALSE);
}
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
return TRUE;
case IDC_DELETE:
{
wchar_t theme[MAX_PATH + 1];
GetDlgItemText(hwndDlg, IDC_THEME, theme, _countof(theme));
int item = SendDlgItemMessage(hwndDlg, IDC_THEME, CB_FINDSTRINGEXACT, -1, (LPARAM)theme);
wchar_t *str = (wchar_t *)SendDlgItemMessage(hwndDlg, IDC_THEME, CB_GETITEMDATA, (WPARAM)item, 0);
if (str)
mir_free(str);
SendDlgItemMessage(hwndDlg, IDC_THEME, CB_DELETESTRING, (WPARAM)item, 0);
if (SendDlgItemMessage(hwndDlg, IDC_THEME, CB_GETCOUNT, 0, 0) == 0) {
SetDlgItemText(hwndDlg, IDC_THEME, L"");
SetDlgItemText(hwndDlg, IDC_CUSTOMSTRING, L"");
EnableWindow(GetDlgItem(hwndDlg, IDC_DELETE), FALSE);
}
else {
SendDlgItemMessage(hwndDlg, IDC_THEME, CB_SETCURSEL, 0, 0);
str = (wchar_t *)SendDlgItemMessage(hwndDlg, IDC_THEME, CB_GETITEMDATA, 0, 0);
if (str)
SetDlgItemText(hwndDlg, IDC_CUSTOMSTRING, str);
}
EnableWindow(GetDlgItem(hwndDlg, IDC_UPDATE), FALSE);
}
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
return TRUE;
case IDC_EXPORT:
{
wchar_t path[MAX_PATH + 1], filter[MAX_PATH + 1], *pfilter;
OPENFILENAME ofn = { 0 };
path[0] = '\0';
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = hwndDlg;
ofn.hInstance = nullptr;
mir_wstrcpy(filter, TranslateT("Keyboard Notify Theme"));
mir_wstrcat(filter, L" (*.knt)");
pfilter = filter + mir_wstrlen(filter) + 1;
mir_wstrcpy(pfilter, L"*.knt");
pfilter = pfilter + mir_wstrlen(pfilter) + 1;
mir_wstrcpy(pfilter, TranslateT("All Files"));
pfilter = pfilter + mir_wstrlen(pfilter) + 1;
mir_wstrcpy(pfilter, L"*.*");
pfilter = pfilter + mir_wstrlen(pfilter) + 1;
*pfilter = '\0';
ofn.lpstrFilter = filter;
ofn.lpstrFile = path;
ofn.Flags = OFN_HIDEREADONLY | OFN_NOCHANGEDIR | OFN_NOREADONLYRETURN | OFN_PATHMUSTEXIST;
ofn.nMaxFile = _countof(path);
ofn.lpstrDefExt = L"knt";
if (GetSaveFileName(&ofn))
exportThemes(path);
}
return TRUE;
case IDC_IMPORT:
{
wchar_t path[MAX_PATH + 1], filter[MAX_PATH + 1], *pfilter;
OPENFILENAME ofn = { 0 };
path[0] = '\0';
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = hwndDlg;
ofn.hInstance = nullptr;
mir_wstrcpy(filter, TranslateT("Keyboard Notify Theme"));
mir_wstrcat(filter, L" (*.knt)");
pfilter = filter + mir_wstrlen(filter) + 1;
mir_wstrcpy(pfilter, L"*.knt");
pfilter = pfilter + mir_wstrlen(pfilter) + 1;
mir_wstrcpy(pfilter, TranslateT("All Files"));
pfilter = pfilter + mir_wstrlen(pfilter) + 1;
mir_wstrcpy(pfilter, L"*.*");
pfilter = pfilter + mir_wstrlen(pfilter) + 1;
*pfilter = '\0';
ofn.lpstrFilter = filter;
ofn.lpstrFile = path;
ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_NOCHANGEDIR;
ofn.nMaxFile = _countof(path);
ofn.lpstrDefExt = L"knt";
if (GetOpenFileName(&ofn)) {
importThemes(path, IsDlgButtonChecked(hwndDlg, IDC_OVERRIDE) == BST_CHECKED);
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
}
}
return TRUE;
case IDC_OVERRIDE:
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
return TRUE;
}
break;
case WM_NOTIFY:
{
int count;
wchar_t theme[MAX_PATH + 1], themeAux[MAX_PATH + 1];
// Here we have pressed either the OK or the APPLY button.
switch (((LPNMHDR)lParam)->idFrom) {
case 0:
switch (((LPNMHDR)lParam)->code) {
case PSN_APPLY:
if (szTheme = g_plugin.getWStringA(fmtDBSettingName("theme%d", wCustomTheme))) {
mir_wstrcpy(theme, szTheme);
mir_free(szTheme);
}
else
theme[0] = '\0';
// Here we will delete all the items in the theme combo on the Flashing tab: we will load them again later
for (int i = 0; SendDlgItemMessage(hwndEffect, IDC_SCUSTOM, CB_DELETESTRING, 0, (LPARAM)i) != CB_ERR; i++);
count = SendDlgItemMessage(hwndDlg, IDC_THEME, CB_GETCOUNT, 0, 0);
for (int i = 0; i < count; i++) {
SendDlgItemMessage(hwndDlg, IDC_THEME, CB_GETLBTEXT, (WPARAM)i, (LPARAM)themeAux);
g_plugin.setWString(fmtDBSettingName("theme%d", i), themeAux);
wchar_t *str = (wchar_t *)SendDlgItemMessage(hwndDlg, IDC_THEME, CB_GETITEMDATA, (WPARAM)i, 0);
if (str)
g_plugin.setWString(fmtDBSettingName("custom%d", i), str);
else
g_plugin.setWString(fmtDBSettingName("custom%d", i), L"");
if (!mir_wstrcmp(theme, themeAux))
wCustomTheme = i;
// Here we will update the theme combo on the Flashing tab: horrible but can't imagine a better way right now
SendDlgItemMessage(hwndEffect, IDC_SCUSTOM, CB_INSERTSTRING, (WPARAM)i, (LPARAM)themeAux);
SendDlgItemMessage(hwndEffect, IDC_SCUSTOM, CB_SETITEMDATA, (WPARAM)i, (LPARAM)i);
}
for (int i = count; !g_plugin.delSetting(fmtDBSettingName("theme%d", i)); i++)
g_plugin.delSetting(fmtDBSettingName("custom%d", i));
g_plugin.setWord("custom", wCustomTheme);
// Still updating here the the Flashing tab's controls
SendDlgItemMessage(hwndEffect, IDC_SCUSTOM, CB_SETCURSEL, (WPARAM)wCustomTheme, 0);
g_plugin.setByte("override", (uint8_t)(IsDlgButtonChecked(hwndDlg, IDC_OVERRIDE) == BST_CHECKED ? 1 : 0));
return TRUE;
} // switch code
break;
} //switch idFrom
}
break; //End WM_NOTIFY
case WM_DESTROY:
int count = SendDlgItemMessage(hwndDlg, IDC_THEME, CB_GETCOUNT, 0, 0);
for (int item = 0; item < count; item++) {
wchar_t *str = (wchar_t *)SendDlgItemMessage(hwndDlg, IDC_THEME, CB_GETITEMDATA, (WPARAM)item, 0);
if (str)
mir_free(str);
}
break;
}
return FALSE;
}
// **
// ** Initialize the Miranda options page
// **
int InitializeOptions(WPARAM wParam, LPARAM)
{
OPTIONSDIALOGPAGE odp = {};
odp.szTitle.a = LPGEN("Keyboard Flash");
odp.szGroup.a = LPGEN("Events");
odp.flags = ODPF_BOLDGROUPS;
odp.szTab.a = LPGEN("Accounts");
odp.pszTemplate = MAKEINTRESOURCEA(IDD_PROTO_OPTIONS);
odp.pfnDlgProc = DlgProcProtoOptions;
g_plugin.addOptions(wParam, &odp);
odp.szTab.a = LPGEN("Rules");
odp.pszTemplate = MAKEINTRESOURCEA(IDD_BASIC_OPTIONS);
odp.pfnDlgProc = DlgProcBasicOptions;
g_plugin.addOptions(wParam, &odp);
odp.szTab.a = LPGEN("Flashing");
odp.pszTemplate = MAKEINTRESOURCEA(IDD_EFFECT_OPTIONS);
odp.pfnDlgProc = DlgProcEffectOptions;
g_plugin.addOptions(wParam, &odp);
odp.szTab.a = LPGEN("Themes");
odp.pszTemplate = MAKEINTRESOURCEA(IDD_THEME_OPTIONS);
odp.pfnDlgProc = DlgProcThemeOptions;
g_plugin.addOptions(wParam, &odp);
odp.szTab.a = LPGEN("Ignore");
odp.pszTemplate = MAKEINTRESOURCEA(IDD_IGNORE_OPTIONS);
odp.pfnDlgProc = DlgProcIgnoreOptions;
g_plugin.addOptions(wParam, &odp);
return 0;
}
|