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
|
/*
* A plugin for Miranda IM which displays web page text in a window Copyright
* (C) 2005 Vincent Joyce.
*
* Miranda IM: the free icq client for MS Windows Copyright (C) 2000-2
* Richard Hughes, Roland Rabien & Tristan Van de Vreede
*
* 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.
*/
/*************/
BOOL CALLBACK DlgProcFind(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
HWND ParentHwnd;
static char Searchstr[128];
static int loc;
static int oldloc;
static int startposition;
static int OLDstartposition;
ParentHwnd = GetParent(hwndDlg);
switch (msg)
{
case WM_INITDIALOG:
{
TranslateDialogDefault(hwndDlg);
SetWindowLong(hwndDlg, GWL_USERDATA, lParam);
SetWindowText(hwndDlg, Translate("Find"));
SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM) LoadIcon(hInst, MAKEINTRESOURCE(IDI_FIND)));
return TRUE;
}
break;
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDC_OK: // find Next
{
char NewSearchstr[128];
char *tempbuffer;
int len;
int location = 0;
int startsel = 0, endsel = 0;
char buff[MAXSIZE1];
ZeroMemory(&NewSearchstr, sizeof(NewSearchstr));
len = GetWindowTextLength(GetDlgItem(ParentHwnd, IDC_DATA));
tempbuffer = malloc(len + 2);
GetWindowText(GetDlgItem(ParentHwnd, IDC_DATA), tempbuffer, len);
strncpy(buff, tempbuffer, sizeof(buff));
free(tempbuffer);
Filter(buff);
CharUpperBuff(buff, lstrlen(buff));
GetDlgItemText(hwndDlg, IDC_FINDWHAT, NewSearchstr, sizeof(NewSearchstr));
CharUpperBuff(NewSearchstr, lstrlen(NewSearchstr));
OLDstartposition = startposition;
if ((strstr(Searchstr, NewSearchstr)) != 0)
{
startposition = loc + strlen(Searchstr);
} else
{
oldloc = 0;
startposition = 0;
}
strcpy(Searchstr, NewSearchstr);
//
/**/
if (!(startposition > strlen(buff)))
location = (strstr(buff + startposition, NewSearchstr)) - buff;
/**/
oldloc = loc;
loc = location;
if (loc == 0)
{
ShowWindow(GetDlgItem(hwndDlg, IDC_SEARCH_COMPLETE), SW_SHOW);
loc = (strstr(buff, NewSearchstr)) - buff;
startsel = loc;
endsel = loc + strlen(NewSearchstr);
oldloc = 0;
startposition = 0;
} else
{
ShowWindow(GetDlgItem(hwndDlg, IDC_SEARCH_COMPLETE), SW_HIDE);
startsel = loc;
endsel = loc + strlen(NewSearchstr);
}
CHARRANGE sel2 = {startsel, endsel};
//
SendMessage(GetDlgItem(ParentHwnd, IDC_DATA), EM_EXSETSEL, 0, (LPARAM) & sel2);
SetFocus(GetDlgItem(ParentHwnd, IDC_DATA));
//
return TRUE;
}
case WM_DESTROY:
case IDC_CANCEL:
{
EnableWindow(GetDlgItem(ParentHwnd, IDC_FIND_BUTTON), 1);
EnableWindow(ParentHwnd, 1);
DestroyWindow(hwndDlg);
}
break;
}
break;
}
return FALSE;
}
/**************/
/*******************************/
BOOL CALLBACK DlgProcDisplayData(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
DBVARIANT dbv;
DBVARIANT dbv2;
DBVARIANT dbv3;
RECT rc;
char url[300];
switch (msg)
{
case WM_INITDIALOG:
{
TranslateDialogDefault(hwndDlg);
//
HANDLE hContact2 = (HANDLE) lParam;
SetWindowLong(hwndDlg, GWL_USERDATA, (LONG) hContact2);
WindowList_Add(hWindowList, hwndDlg, hContact2);
// //
url[0] = '\0';
DBGetContactSetting(hContact2, DLLNAME, URL_KEY, &dbv);
_snprintf(url, sizeof(url), "%s", dbv.pszVal);
DBFreeVariant(&dbv);
// //
char buttontext[256];
char stringbefore[256];
char *stringafter;
char newbuttontext[256];
int pos = 0;
int posafter = 0;
int posbefore = 0;
ZeroMemory(&buttontext, sizeof(buttontext));
ZeroMemory(&newbuttontext, sizeof(newbuttontext));
_snprintf(buttontext, sizeof(buttontext), "%s", url);
_snprintf(newbuttontext, sizeof(newbuttontext), "%s", url);
if ((strstr(newbuttontext, "&")) != 0)
{
while (1)
{
ZeroMemory(&stringbefore, sizeof(stringbefore));
if ((strstr(newbuttontext, "&")) == 0)
break;
_snprintf(buttontext, sizeof(buttontext), "%s", newbuttontext);
stringafter = strstr(buttontext, "&");
pos = (stringafter - buttontext);
posbefore = (stringafter - buttontext) - 1;
posafter = (stringafter - buttontext) + 1;
strncpy(&stringafter[0], &stringafter[1], strlen(stringafter));
_snprintf(stringbefore, pos, "%s", buttontext);
_snprintf(newbuttontext, sizeof(buttontext), "%s%s%s", stringbefore, "!!", stringafter);
posafter = 0;
posbefore = 0;
}
while (1)
{
if ((strstr(newbuttontext, "!")) != 0)
{
stringafter = strstr(newbuttontext, "!");
pos = (stringafter - newbuttontext);
newbuttontext[pos] = '&';
}
if ((strstr(newbuttontext, "!")) == 0)
break;
}
}
SetDlgItemText(hwndDlg, IDC_OPEN_URL, newbuttontext);
//SetDlgItemText(hwndDlg, IDC_HIDDEN_URL, url);
// //
//
char preservename[100];
ZeroMemory(&preservename, sizeof(preservename));
DBGetContactSetting(hContact2, DLLNAME, PRESERVE_NAME_KEY, &dbv);
_snprintf(preservename, sizeof(preservename), "%s", dbv.pszVal);
DBFreeVariant(&dbv);
SetWindowText(hwndDlg, preservename);
//
SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM) LoadIcon(hInst, MAKEINTRESOURCE(IDI_SITE)));
// //////
COLORREF colour;
COLORREF txtcolor;
colour = BackgoundClr;
SendDlgItemMessage(hwndDlg, IDC_DATA, EM_SETBKGNDCOLOR, 0, colour);
// /////
// //
SendDlgItemMessage(hwndDlg, IDC_UPDATE_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM) ((HICON) LoadImage(hInst, MAKEINTRESOURCE(IDI_UPDATE), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0)));
SendMessage(GetDlgItem(hwndDlg, IDC_UPDATE_BUTTON), BUTTONADDTOOLTIP, (WPARAM) Translate("Update Data"), 0);
SendDlgItemMessage(hwndDlg, IDC_FIND_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM) ((HICON) LoadImage(hInst, MAKEINTRESOURCE(IDI_FIND), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0)));
SendMessage(GetDlgItem(hwndDlg, IDC_FIND_BUTTON), BUTTONADDTOOLTIP, (WPARAM) Translate("Find"), 0);
SendDlgItemMessage(hwndDlg, IDC_OPTIONS_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM) ((HICON) LoadImage(hInst, MAKEINTRESOURCE(IDI_OPTIONS), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0)));
SendMessage(GetDlgItem(hwndDlg, IDC_OPTIONS_BUTTON), BUTTONADDTOOLTIP, (WPARAM) Translate("Contact Options"), 0);
SendDlgItemMessage(hwndDlg, IDC_ALERT_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM) ((HICON) LoadImage(hInst, MAKEINTRESOURCE(IDI_ALERT), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0)));
SendMessage(GetDlgItem(hwndDlg, IDC_ALERT_BUTTON), BUTTONADDTOOLTIP, (WPARAM) Translate("Alert Options"), 0);
SendDlgItemMessage(hwndDlg, IDC_STOP, BM_SETIMAGE, IMAGE_ICON, (LPARAM) ((HICON) LoadImage(hInst, MAKEINTRESOURCE(IDI_STOP), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0)));
SendMessage(GetDlgItem(hwndDlg, IDC_STOP), BUTTONADDTOOLTIP, (WPARAM) Translate("Stop Processing"), 0);
// ///
SendMessage(GetDlgItem(hwndDlg, IDC_OPEN_URL), BUTTONADDTOOLTIP, (WPARAM) Translate("Click here to open this URL in a browser window."), 0);
// ///
if (!(DBGetContactSettingByte(hContact2, DLLNAME, ON_TOP_KEY, 0)))
{//
SendDlgItemMessage(hwndDlg, IDC_STICK_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM) ((HICON) LoadImage(hInst, MAKEINTRESOURCE(IDI_UNSTICK), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0)));
SendMessage(GetDlgItem(hwndDlg, IDC_STICK_BUTTON), BUTTONADDTOOLTIP, (WPARAM) Translate("Stick to the front"), 0);
}
if (DBGetContactSettingByte(hContact2, DLLNAME, ON_TOP_KEY, 0))
{
SendDlgItemMessage(hwndDlg, IDC_STICK_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM) ((HICON) LoadImage(hInst, MAKEINTRESOURCE(IDI_STICK), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0)));
SendMessage(GetDlgItem(hwndDlg, IDC_STICK_BUTTON), BUTTONADDTOOLTIP, (WPARAM) Translate("Disable Stick to the Front"), 0);
}
// //
SendMessage(GetDlgItem(hwndDlg, IDC_DATA), WM_SETFONT, (WPARAM) h_font, 1);
txtcolor = TextClr;
SetDlgItemText(hwndDlg, IDC_DATA, "");
InvalidateRect(hwndDlg, NULL, 1);
//
// /
SendMessage(GetDlgItem(hwndDlg, IDC_DATA), EM_AUTOURLDETECT, 1, 0);
int mask = (int) SendMessage(GetDlgItem(hwndDlg, IDC_DATA), EM_GETEVENTMASK, 0, 0);
SendMessage(GetDlgItem(hwndDlg, IDC_DATA), EM_SETEVENTMASK, 0, mask | ENM_LINK | ENM_MOUSEEVENTS);
// /
SendDlgItemMessage(hwndDlg, IDC_STICK_BUTTON, BUTTONSETASFLATBTN, 0, 0);
SendDlgItemMessage(hwndDlg, IDC_UPDATE_BUTTON, BUTTONSETASFLATBTN, 0, 0);
SendDlgItemMessage(hwndDlg, IDC_FIND_BUTTON, BUTTONSETASFLATBTN, 0, 0);
SendDlgItemMessage(hwndDlg, IDC_OPTIONS_BUTTON, BUTTONSETASFLATBTN, 0, 0);
SendDlgItemMessage(hwndDlg, IDC_ALERT_BUTTON, BUTTONSETASFLATBTN, 0, 0);
SendDlgItemMessage(hwndDlg, IDC_STOP, BUTTONSETASFLATBTN, 0, 0);
//
SendDlgItemMessage(hwndDlg, IDC_OPEN_URL, BUTTONSETASFLATBTN, 0, 0);
//
{
int partWidth[2];
SIZE textSize;
HDC hdc;
hdc = GetDC(GetDlgItem(hwndDlg, IDC_STATUSBAR));
SelectObject(hdc, (HFONT) SendDlgItemMessage(hwndDlg, IDC_STATUSBAR, WM_GETFONT, 0, 0));
GetTextExtentPoint32(hdc, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", lstrlen("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"), &textSize);
partWidth[0] = textSize.cx;
ReleaseDC(GetDlgItem(hwndDlg, IDC_STATUSBAR), hdc);
partWidth[1] = -1;
SendDlgItemMessage(hwndDlg, IDC_STATUSBAR, SB_SETPARTS, sizeof(partWidth) / sizeof(partWidth[0]), (LPARAM) partWidth);
SendDlgItemMessage(hwndDlg, IDC_STATUSBAR, SB_SETTEXT, 1 | SBT_OWNERDRAW, 0);
}
//
if ((DBGetContactSettingByte(NULL, DLLNAME, SAVE_INDIVID_POS_KEY, 0)))
Utils_RestoreWindowPosition(hwndDlg, hContact2, DLLNAME, "WV");
}
break;
// //////////
case WM_NOTIFY:
switch (((NMHDR *) lParam)->code)
{
//
case EN_MSGFILTER:
switch (((MSGFILTER *) lParam)->msg)
{
case WM_RBUTTONUP:
{
HMENU hSubMenu;
POINT pt;
CHARRANGE sel, all = {0, -1};
hSubMenu = GetSubMenu(hMenu, 0);
CallService(MS_LANGPACK_TRANSLATEMENU, (WPARAM) hSubMenu, 0);
SendMessage(((NMHDR *) lParam)->hwndFrom, EM_EXGETSEL, 0, (LPARAM) & sel);
EnableMenuItem(hSubMenu, IDM_COPY, MF_ENABLED);
EnableMenuItem(hSubMenu, IDM_CUT, MF_ENABLED);
EnableMenuItem(hSubMenu, IDM_DELETE, MF_ENABLED);
if (sel.cpMin == sel.cpMax)
{
EnableMenuItem(hSubMenu, IDM_COPY, MF_BYCOMMAND | MF_GRAYED);
EnableMenuItem(hSubMenu, IDM_CUT, MF_BYCOMMAND | MF_GRAYED);
EnableMenuItem(hSubMenu, IDM_DELETE, MF_BYCOMMAND | MF_GRAYED);
}
pt.x = (short) LOWORD(((ENLINK *) lParam)->lParam);
pt.y = (short) HIWORD(((ENLINK *) lParam)->lParam);
ClientToScreen(((NMHDR *) lParam)->hwndFrom, &pt);
switch (TrackPopupMenu(hSubMenu, TPM_RETURNCMD, pt.x, pt.y, 0, hwndDlg, NULL))
{
case IDM_COPY:
{
SendMessage(((NMHDR *) lParam)->hwndFrom, WM_COPY, 0, 0);
}
break;
case IDM_COPYALL:
{
SendMessage(((NMHDR *) lParam)->hwndFrom, EM_EXSETSEL, 0, (LPARAM) & all);
SendMessage(((NMHDR *) lParam)->hwndFrom, WM_COPY, 0, 0);
SendMessage(((NMHDR *) lParam)->hwndFrom, EM_EXSETSEL, 0, (LPARAM) & sel);
}
break;
case IDM_SELECTALL:
{
SendMessage(((NMHDR *) lParam)->hwndFrom, EM_EXSETSEL, 0, (LPARAM) & all);
}
break;
case IDM_CUT:
{
SendMessage(((NMHDR *) lParam)->hwndFrom, WM_CUT, 0, 0);
}
break;
case IDM_PASTE:
{
SendMessage(((NMHDR *) lParam)->hwndFrom, WM_PASTE, 0, 0);
}
break;
case IDM_DELETE:
{
SendMessage(((NMHDR *) lParam)->hwndFrom, WM_CLEAR, 0, 0);
}
break;
case IDM_CLEAR_ALL:
{
SetDlgItemText(hwndDlg, IDC_DATA, "");
SetFocus(GetDlgItem(hwndDlg, IDC_DATA));
}
break;
}
}
}
break;
//
case EN_LINK:
switch (((ENLINK *) lParam)->msg)
{
case WM_RBUTTONDOWN:
case WM_LBUTTONUP:
{
TEXTRANGE tr;
CHARRANGE sel;
SendDlgItemMessage(hwndDlg, IDC_DATA, EM_EXGETSEL, 0, (LPARAM) & sel);
if (sel.cpMin != sel.cpMax)
break;
tr.chrg = ((ENLINK *) lParam)->chrg;
tr.lpstrText = malloc(tr.chrg.cpMax - tr.chrg.cpMin + 8);
SendDlgItemMessage(hwndDlg, IDC_DATA, EM_GETTEXTRANGE, 0, (LPARAM) & tr);
/*
#ifdef UNICODE_VERISON
if (wcschr(tr.lpstrText, '@') != NULL && wcschr(tr.lpstrText, ':') == NULL && wcschr(tr.lpstrText, '/') == NULL)
{
MoveMemory(tr.lpstrText + 7, tr.lpstrText, tr.chrg.cpMax - tr.chrg.cpMin + 1);
CopyMemory(tr.lpstrText, "mailto:", 7);
}
#endif
*/
//#ifndef UNICODE_VERISON
if (strchr(tr.lpstrText, '@') != NULL && strchr(tr.lpstrText, ':') == NULL && strchr(tr.lpstrText, '/') == NULL)
{
MoveMemory(tr.lpstrText + 7, tr.lpstrText, tr.chrg.cpMax - tr.chrg.cpMin + 1);
CopyMemory(tr.lpstrText, "mailto:", 7);
}
//#endif
CallService(MS_UTILS_OPENURL, 1, (LPARAM) tr.lpstrText);
SetFocus(GetDlgItem(hwndDlg, IDC_DATA));
free(tr.lpstrText);
break;
}
}
break;
}
break; // notify
// ///////////
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDC_OPEN_URL:
{
ZeroMemory(&url, sizeof(url));
GetDlgItemText(hwndDlg, IDC_OPEN_URL, url, sizeof(url));
CallService(MS_UTILS_OPENURL, 1, (LPARAM) url);
DBWriteContactSettingWord((HANDLE) wParam, DLLNAME, "Status", ID_STATUS_ONLINE);
}
break;
case IDC_UPDATE_BUTTON:
{
HANDLE hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDFIRST, 0, 0);
char *szProto;
char urltext[300];
char titlebartxt[300];
int contactcount = 0;
ZeroMemory(&urltext, sizeof(urltext));
ZeroMemory(&titlebartxt, sizeof(titlebartxt));
//GetDlgItemText(hwndDlg, IDC_HIDDEN_URL, urltext, sizeof(urltext));
GetDlgItemText(hwndDlg, IDC_OPEN_URL, urltext, sizeof(urltext));
GetWindowText(hwndDlg, titlebartxt, sizeof(titlebartxt));
while (hContact != NULL)
{
szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0);
if (szProto != NULL && !lstrcmp(DLLNAME, szProto))
{
DBGetContactSetting(hContact, DLLNAME, URL_KEY, &dbv);
DBGetContactSetting(hContact, DLLNAME, PRESERVE_NAME_KEY, &dbv2);
if ((!lstrcmp(urltext, dbv.pszVal)) && (!lstrcmp(titlebartxt, dbv2.pszVal)))
{
contactcount++;
if (contactcount > 1)
{
MessageBox(NULL, Translate("ERROR: You have two or more Webview contacts with the same URL and contact name."), DLLNAME, MB_OK);
break;
}
EnableWindow(GetDlgItem(hwndDlg, IDC_UPDATE_BUTTON), 0);
UpdateMenuCommand(wParam, lParam, hContact);
}
DBFreeVariant(&dbv);
DBFreeVariant(&dbv2);
}
hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM) hContact, 0);
}
}
break;
case IDC_STOP:
{
HANDLE hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDFIRST, 0, 0);
char *szProto;
char urltext[300];
char titlebartxt[300];
int contactcount = 0;
ZeroMemory(&urltext, sizeof(urltext));
ZeroMemory(&titlebartxt, sizeof(titlebartxt));
//GetDlgItemText(hwndDlg, IDC_HIDDEN_URL, urltext, sizeof(urltext));
GetDlgItemText(hwndDlg, IDC_OPEN_URL, urltext, sizeof(urltext));
GetWindowText(hwndDlg, titlebartxt, sizeof(titlebartxt));
while (hContact != NULL)
{
szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0);
if (szProto != NULL && !lstrcmp(DLLNAME, szProto))
{
DBGetContactSetting(hContact, DLLNAME, URL_KEY, &dbv);
DBGetContactSetting(hContact, DLLNAME, PRESERVE_NAME_KEY, &dbv2);
if ((!lstrcmp(urltext, dbv.pszVal)) && (!lstrcmp(titlebartxt, dbv2.pszVal)))
{
contactcount++;
if (contactcount > 1)
{
MessageBox(NULL, Translate("ERROR: You have two or more Webview contacts with the same URL and contact name."), DLLNAME, MB_OK);
break;
}
DBWriteContactSettingByte(hContact, DLLNAME, STOP_KEY, 1);
}
DBFreeVariant(&dbv);
DBFreeVariant(&dbv2);
}
hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM) hContact, 0);
}
}
break;
case IDC_STICK_BUTTON:
{
// /////////
HANDLE hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDFIRST, 0, 0);
char *szProto;
char urltext2[300];
char titlebartxt[300];
int contactcount = 0;
ZeroMemory(&urltext2, sizeof(urltext2));
ZeroMemory(&titlebartxt, sizeof(titlebartxt));
//GetDlgItemText(hwndDlg, IDC_HIDDEN_URL, urltext2, sizeof(urltext2));
GetDlgItemText(hwndDlg, IDC_OPEN_URL, urltext2, sizeof(urltext2));
GetWindowText(hwndDlg, titlebartxt, sizeof(titlebartxt));
while (hContact != NULL)
{
szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0);
if (szProto != NULL && !lstrcmp(DLLNAME, szProto))
{
DBGetContactSetting(hContact, DLLNAME, URL_KEY, &dbv);
DBGetContactSetting(hContact, DLLNAME, PRESERVE_NAME_KEY, &dbv2);
if ((!lstrcmp(urltext2, dbv.pszVal)) && (!lstrcmp(titlebartxt, dbv2.pszVal)))
{
contactcount++;
if (contactcount > 1)
{
MessageBox(NULL, Translate("ERROR: You have two or more Webview contacts with the same URL and contact name."), DLLNAME, MB_OK);
break;
}
OnTopMenuCommand(wParam, lParam, hContact);
DBFreeVariant(&dbv);
break;
}
DBFreeVariant(&dbv);
DBFreeVariant(&dbv2);
}
hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM) hContact, 0);
}
//
// ////////
if (!(DBGetContactSettingByte(hContact, DLLNAME, ON_TOP_KEY, 0)))
{//
SendDlgItemMessage(hwndDlg, IDC_STICK_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM) ((HICON) LoadImage(hInst, MAKEINTRESOURCE(IDI_UNSTICK), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0)));
SendMessage(GetDlgItem(hwndDlg, IDC_STICK_BUTTON), BUTTONADDTOOLTIP, (WPARAM) Translate("Stick to the front"), 0);
if ((DBGetContactSettingByte(NULL, DLLNAME, SAVE_INDIVID_POS_KEY, 0)))
{
SetWindowPos(
hwndDlg,
HWND_NOTOPMOST,
0, // Xposition,
0, // Yposition,
0, // WindowWidth,
0, // WindowHeight,
SWP_NOSIZE | SWP_NOMOVE);
} else
{
SetWindowPos(
hwndDlg,
HWND_NOTOPMOST,
0,
0,
0,
0,
SWP_NOSIZE | SWP_NOMOVE);
}
}
if (DBGetContactSettingByte(hContact, DLLNAME, ON_TOP_KEY, 0))
{
SendDlgItemMessage(hwndDlg, IDC_STICK_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM) ((HICON) LoadImage(hInst, MAKEINTRESOURCE(IDI_STICK), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0)));
SendMessage(GetDlgItem(hwndDlg, IDC_STICK_BUTTON), BUTTONADDTOOLTIP, (WPARAM) Translate("Disable Stick to the front"), 0);
if ((DBGetContactSettingByte(NULL, DLLNAME, SAVE_INDIVID_POS_KEY, 0)))
{
SetWindowPos(
hwndDlg,
HWND_TOPMOST,
0, // Xposition,
0, // Yposition,
0, // WindowWidth,
0, // WindowHeight,
SWP_NOSIZE | SWP_NOMOVE);
} else
{
SetWindowPos(
hwndDlg,
HWND_TOPMOST,
0,
0,
0,
0,
SWP_NOSIZE | SWP_NOMOVE);
}
}
DBFreeVariant(&dbv);
}
break;
// //
case IDC_FIND_BUTTON:
{
HWND hwndFind;
hwndFind = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_FIND), hwndDlg, DlgProcFind, (LPARAM) (HANDLE) wParam);
ShowWindow(hwndFind, SW_SHOW);
EnableWindow(GetDlgItem(hwndDlg, IDC_FIND_BUTTON), 0);
}
break;
case IDC_OPTIONS_BUTTON:
{
HANDLE hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDFIRST, 0, 0);
char *szProto;
char urltext[300];
char titlebartxt[300];
int contactcount = 0;
//
ZeroMemory(&urltext, sizeof(urltext));
ZeroMemory(&titlebartxt, sizeof(titlebartxt));
//GetDlgItemText(hwndDlg, IDC_HIDDEN_URL, urltext, sizeof(urltext));
GetDlgItemText(hwndDlg, IDC_OPEN_URL, urltext, sizeof(urltext));
GetWindowText(hwndDlg, titlebartxt, sizeof(titlebartxt));
while (hContact != NULL)
{
szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0);
if (szProto != NULL && !lstrcmp(DLLNAME, szProto))
{
DBGetContactSetting(hContact, DLLNAME, URL_KEY, &dbv);
DBGetContactSetting(hContact, DLLNAME, PRESERVE_NAME_KEY, &dbv2);
if ((!lstrcmp(urltext, dbv.pszVal)) && (!lstrcmp(titlebartxt, dbv2.pszVal)))
{
contactcount++;
if (contactcount > 1)
{
MessageBox(NULL, Translate("ERROR: You have two or more Webview contacts with the same URL and contact name."), DLLNAME, MB_OK);
break;
}
ContactHwnd = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_CONTACT_OPT), hwndDlg, DlgProcContactOpt, (LPARAM) (HANDLE) hContact);
ShowWindow(ContactHwnd, SW_SHOW);
SetActiveWindow(ContactHwnd);
EnableWindow(GetDlgItem(hwndDlg, IDC_OPTIONS_BUTTON), 0);
EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_BUTTON), 0);
}
DBFreeVariant(&dbv);
DBFreeVariant(&dbv2);
}
hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM) hContact, 0);
}
//
}
break;
// ///
case IDC_ALERT_BUTTON:
{
HWND hwndAlertOpt;
HANDLE hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDFIRST, 0, 0);
char *szProto;
char urltext[300];
char titlebartxt[300];
int contactcount = 0;
//
ZeroMemory(&urltext, sizeof(urltext));
ZeroMemory(&titlebartxt, sizeof(titlebartxt));
//GetDlgItemText(hwndDlg, IDC_HIDDEN_URL, urltext, sizeof(urltext));
GetDlgItemText(hwndDlg, IDC_OPEN_URL, urltext, sizeof(urltext));
GetWindowText(hwndDlg, titlebartxt, sizeof(titlebartxt));
while (hContact != NULL)
{
szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0);
if (szProto != NULL && !lstrcmp(DLLNAME, szProto))
{
DBGetContactSetting(hContact, DLLNAME, URL_KEY, &dbv);
DBGetContactSetting(hContact, DLLNAME, PRESERVE_NAME_KEY, &dbv2);
if ((!lstrcmp(urltext, dbv.pszVal)) && (!lstrcmp(titlebartxt, dbv2.pszVal)))
{
contactcount++;
if (contactcount > 1)
{
MessageBox(NULL, Translate("ERROR: You have two or more Webview contacts with the same URL and contact name."), DLLNAME, MB_OK);
break;
}
hwndAlertOpt = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_ALRT_OPT), hwndDlg, DlgProcAlertOpt, (LPARAM) (HANDLE) hContact);
ShowWindow(hwndAlertOpt, SW_SHOW);
SetActiveWindow(hwndAlertOpt);
EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_BUTTON), 0);
EnableWindow(GetDlgItem(hwndDlg, IDC_OPTIONS_BUTTON), 0);
}
DBFreeVariant(&dbv);
DBFreeVariant(&dbv2);
}
hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM) hContact, 0);
}
}
break;
case IDOK:
case IDCANCEL:
if (hwndDlg != NULL)
DestroyWindow(hwndDlg);
return TRUE;
}
break;
break;
case WM_CLOSE:
{
//
HANDLE hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDFIRST, 0, 0);
char *szProto;
char urltext[300];
char titlebartxt[300];
int contactcount = 0;
if (Yposition == -32000)
Yposition = 100;
if (Xposition == -32000)
Xposition = 100;
SavewinSettings();
/**/
//
ZeroMemory(&urltext, sizeof(urltext));
ZeroMemory(&titlebartxt, sizeof(titlebartxt));
//GetDlgItemText(hwndDlg, IDC_HIDDEN_URL, urltext, sizeof(urltext));
GetDlgItemText(hwndDlg, IDC_OPEN_URL, urltext, sizeof(urltext));
GetWindowText(hwndDlg, titlebartxt, sizeof(titlebartxt));
while (hContact != NULL)
{
szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0);
if (szProto != NULL && !lstrcmp(DLLNAME, szProto))
{
DBGetContactSetting(hContact, DLLNAME, URL_KEY, &dbv);
DBGetContactSetting(hContact, DLLNAME, PRESERVE_NAME_KEY, &dbv2);
if ((!lstrcmp(urltext, dbv.pszVal)) && (!lstrcmp(titlebartxt, dbv2.pszVal)))
{
contactcount++;
if (contactcount > 1)
break;
//
Utils_SaveWindowPosition(hwndDlg, hContact, DLLNAME, "WV");
//
}
DBFreeVariant(&dbv);
DBFreeVariant(&dbv2);
}
hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM) hContact, 0);
}
/**/
if (hwndDlg != NULL)
DestroyWindow(hwndDlg);
return 0;
break;
}
case WM_DESTROY:
{
WindowList_Remove(hWindowList, hwndDlg);
return 0;
break;
}
case WM_SIZE:
{
UTILRESIZEDIALOG urd = {0};
urd.cbSize = sizeof(urd);
urd.hInstance = hInst;
urd.hwndDlg = hwndDlg;
urd.lParam = 0;
urd.lpTemplate = MAKEINTRESOURCE(IDD_DISPLAY_DATA);
urd.pfnResizer = DataDialogResize;
CallService(MS_UTILS_RESIZEDIALOG, 0, (LPARAM) & urd);
InvalidateRect(hwndDlg, NULL, TRUE);
GetWindowRect(hwndDlg, &rc);
// global
Xposition = rc.left;
Yposition = rc.top;
WindowHeight = rc.bottom - rc.top;
WindowWidth = rc.right - rc.left;
break;
}
case WM_MOVE:
if ((!IsIconic(hwndDlg)) && (!IsZoomed(hwndDlg)))
{
GetWindowRect(hwndDlg, &rc);
// global
Xposition = rc.left;
Yposition = rc.top;
WindowHeight = rc.bottom - rc.top;
WindowWidth = rc.right - rc.left;
if ((GetAsyncKeyState(VK_CONTROL) & 0x8000))
{
break;
return 0;
}
ValidatePosition(hwndDlg);
}
}
return FALSE;
}
/***********************/
/*****************************/
int DataDialogResize(HWND hwndDlg, LPARAM lParam, UTILRESIZECONTROL * urc)
{
switch (urc->wId)
{
case IDC_OPEN_URL:
return RD_ANCHORX_WIDTH | RD_ANCHORY_TOP;
case IDC_DATA:
return RD_ANCHORX_WIDTH | RD_ANCHORY_HEIGHT;
case IDC_STATUSBAR:
return RD_ANCHORX_WIDTH | RD_ANCHORX_RIGHT;
}
return RD_ANCHORX_LEFT | RD_ANCHORY_TOP;
}
/****************************/
/************/
void SavewinSettings(void)
{
if (Yposition == -32000)
Yposition = 100;
if (Xposition == -32000)
Xposition = 100;
DBWriteContactSettingDword(NULL, DLLNAME, Xpos_WIN_KEY, Xposition);
DBWriteContactSettingDword(NULL, DLLNAME, Ypos_WIN_KEY, Yposition);
DBWriteContactSettingDword(NULL, DLLNAME, BG_COLOR_KEY, BackgoundClr);
DBWriteContactSettingDword(NULL, DLLNAME, TXT_COLOR_KEY, TextClr);
DBWriteContactSettingDword(NULL, DLLNAME, WIN_HEIGHT_KEY, WindowHeight);
DBWriteContactSettingDword(NULL, DLLNAME, WIN_WIDTH_KEY, WindowWidth);
}
/************/
/************************/
void ValidatePosition(HWND hwndDlg)
{
RECT r;
POINT pt;
typedef HMONITOR WINAPI MyMonitorFromPoint(POINT, DWORD);
typedef BOOL WINAPI MyGetMonitorInfo(HMONITOR, LPMONITORINFO);
HMODULE hUserInstance = GetModuleHandle("user32");
SystemParametersInfo(SPI_GETWORKAREA, 0, &r, 0);
MyMonitorFromPoint *LPMyMonitorFromPoint = (MyMonitorFromPoint *) GetProcAddress(hUserInstance, "MonitorFromPoint");
if (LPMyMonitorFromPoint)
{
MONITORINFO monitorInfo;
HMONITOR hMonitor = LPMyMonitorFromPoint(pt, MONITOR_DEFAULTTONEAREST); // always
//
// returns
// a
// valid
// value
monitorInfo.cbSize = sizeof(MONITORINFO);
if ((MyGetMonitorInfo *) GetProcAddress(hUserInstance, "GetMonitorInfoA") (hMonitor, &monitorInfo))
{
CopyMemory(&r, &monitorInfo.rcMonitor, sizeof(RECT));
}
}
// /window going off right of screen*
if (((Xposition) + WindowWidth) >= r.right)
{
Xposition = r.right - WindowWidth;
}
// window going off bottom of screen
if (((Yposition) + (WindowHeight)) >= r.bottom)
{
Yposition = (r.bottom - (WindowHeight));
}
// window going off left of screen
if (((Xposition)) >= r.right)
{
Xposition = 0;
}
}
/***********************/
|