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
|
{}
(*
const
MenuServices:array [tMenuType] of pAnsiChar = (
'CList/AddMainMenuItem' {MS_CLIST_ADDMAINMENUITEM },
'CList/AddContactMenuItem'{MS_CLIST_ADDCONTACTMENUITEM},
'CList/AddTrayMenuItem' {MS_CLIST_ADDTRAYMENUITEM },
'CList/AddProtoMenuItem' {MS_CLIST_ADDPROTOMENUITEM },
'CList/AddStatusMenuItem' {MS_CLIST_ADDSTATUSMENUITEM }
);
*)
type
tuaMenuRec = record
hMenuRoot:HMENU;
position :integer;
end;
tuaMenuRecA = array [tMenuType] of tuaMenuRec;
var
arMenuRec: array of tuaMenuRecA;
//===== Support =====
function ServiceCallWithLParam(wParam:WPARAM; lParam:LPARAM):int_ptr; cdecl;
begin
result:=CallService(MS_ACT_RUNBYID, lParam, wParam);
end;
procedure SetTTBState(const ActionItem:tMyActionItem);
var
lflag:integer;
begin
if ActionItem.hTTBButton=0 then exit;
if (ActionItem.flags and UAF_2STATE)=0 then exit;
lflag:=CallService(MS_TTB_GETBUTTONSTATE,ActionItem.hTTBButton,0);
if lflag=TTBST_PUSHED then
begin
if (ActionItem.flags and (UAF_2STATE+UAF_PRESSED))<>(UAF_2STATE+UAF_PRESSED) then exit;
lflag:=TTBST_RELEASED;
end
else
begin
if (ActionItem.flags and (UAF_2STATE+UAF_PRESSED))=(UAF_2STATE+UAF_PRESSED) then exit;
if (ActionItem.flags and UAF_PRESSED)=0 then exit;
lflag:=TTBST_PUSHED;
end;
CallService(MS_TTB_SETBUTTONSTATE,ActionItem.hTTBButton,lflag);
end;
procedure SetTABState(hContact:THANDLE;const ActionItem:tMyActionItem;pressed:integer);
var
tabb:BBButton;
pc:pWideChar;
begin
FillChar(tabb,SizeOf(tabb),0);
tabb.cbSize :=SizeOf(tabb);
tabb.dwButtonID :=ActionItem.dwActID;
tabb.pszModuleName:=MODULE_NAME;
if pressed<>0 then
begin
pc:=ActionItem.szTabBTooltipPressed;
if pc=nil then pc:=ActionItem.szTabBTooltip;
tabb.hIcon:=ActionItem.hIcolibIconPressed;
tabb.bbbFlags:=BBSF_PUSHED;
end
else
begin
pc:=ActionItem.szTabBTooltip;
tabb.hIcon:=ActionItem.hIcolibIcon;
tabb.bbbFlags:=BBSF_RELEASED;
end;
if pc=nil then pc:=ActionItem.szActDescr;
tabb.szTooltip.w:=pc;
CallService(MS_BB_SETBUTTONSTATE,hContact,TLPARAM(@tabb));
end;
function IsLocalItem(const UAItem:tMyActionItem):boolean;
begin
result:=((UAItem.flags and UAF_GLOBAL)=0) and
(UAItem.UAMenuItem[main_menu ].hMenuItem=0) and
(UAItem.UAMenuItem[tray_menu ].hMenuItem=0) and
(UAItem.UAMenuItem[proto_menu ].hMenuItem=0) and
(UAItem.UAMenuItem[status_menu].hMenuItem=0) and
(UAItem.hTTBButton=0);
end;
function ServiceCallWithFParam(wParam:WPARAM; lParam:LPARAM; fParam:LPARAM):int_ptr; cdecl;
var
i:integer;
setting:array [0..63] of AnsiChar;
p:pAnsiChar;
cnt:THANDLE;
state:integer;
begin
for i:=0 to HIGH(UActionList) do
begin
with UActionList[i] do
if dwActID=cardinal(fParam) then
if (flags and UAF_2STATE)<>0 then
begin
// sync buttons/menus
if IsLocalItem(UActionList[i]) then
begin
// if (flags and UAF_SAVESTATE)<>0 then
begin
state:=DBReadByte(lastContact,opt_ua,szNameID);
state:=state xor 1;
DBWriteByte(lastContact,opt_ua,szNameID,state);
cnt:=lastContact;
end;
end
else
begin
flags:=flags xor UAF_PRESSED;
// save "pressed" state
if (flags and UAF_SAVESTATE)<>0 then
begin
p:=GetUABranch(setting,dwActID);
if p<>nil then
begin
p:=StrCopyE(p,opt_ua);
p^:='/'; inc(p);
StrCopy(p,opt_flags);
DBWriteDWord(0,DBBranch,setting,flags and not UAF_REALTIME);
end;
end;
if hTTBButton<>0 then
SetTTBState(UActionList[i]);
cnt:=0;
state:=ORD(flags and UAF_PRESSED);
end;
if (flags and UAF_REGTABB)<>0 then
SetTABState(cnt,UActionList[i],state);
break;
end;
end;
result:=CallService(MS_ACT_RUNBYID, fParam, wParam);
end;
function AddIcolibIconP(var ActionItem:tMyActionItem):THANDLE;
var
sid:TSKINICONDESC;
buf,buf1:array [0..63] of WideChar;
begin
if (ActionItem.hIcolibIconPressed=0) or
(ActionItem.hIcolibIconPressed=ActionItem.hIcolibIcon) then
begin
// add icon for action to icolib
fillChar(sid,SizeOf(sid),0);
sid.cbSize :=sizeof(sid);
sid.szSection .w:=ICOLIB_ACTSECTION;
sid.szDefaultFile.w:=szMyPath;
sid.iDefaultIndex :=-IDI_ACTION;
sid.cx :=16;
sid.cy :=16;
sid.flags :=SIDF_ALL_UNICODE;
// icon "off"
StrCopyW(StrCopyEW(buf,ActionItem.szActDescr),' (pressed)');
sid.szDescription.w:=@buf;
StrCopy(StrCopyE(@buf1,ActionItem.szNameID),'_pressed');
sid.pszName :=@buf1;
ActionItem.hIcolibIconPressed:=Skin_AddIcon(@sid);
end;
result:=ActionItem.hIcolibIconPressed;
end;
function AddIcolibIcon(var ActionItem:tMyActionItem):THANDLE;
var
sid:TSKINICONDESC;
begin
if ActionItem.hIcolibIcon=0 then
begin
// add icon for action to icolib
fillChar(sid,SizeOf(sid),0);
sid.cbSize :=sizeof(sid);
sid.szSection .w:=ICOLIB_ACTSECTION;
sid.szDefaultFile.w:=szMyPath;
sid.iDefaultIndex :=-IDI_ACTION;
sid.cx :=16;
sid.cy :=16;
sid.flags :=SIDF_ALL_UNICODE;
// icon "on"
sid.szDescription.w:=ActionItem.szActDescr;
sid.pszName :=ActionItem.szNameID;
ActionItem.hIcolibIcon:=Skin_AddIcon(@sid);
end;
result:=ActionItem.hIcolibIcon;
end;
procedure DeleteIcolibIconP(var ActionItem:tMyActionItem);
var
buf1:array [0..63] of WideChar;
begin
if (ActionItem.hIcolibIconPressed<>0) and
(ActionItem.hIcolibIconPressed<>ActionItem.hIcolibIcon) then
begin
StrCopy(StrCopyE(@buf1,ActionItem.szNameID),'_pressed');
CallService(MS_SKIN2_REMOVEICON,0,LPARAM(@buf1));
ActionItem.hIcolibIconPressed:=ActionItem.hIcolibIcon;
end;
end;
procedure DeleteIcolibIcon(var ActionItem:tMyActionItem);
begin
DeleteIcolibIconP(ActionItem);
CallService(MS_SKIN2_REMOVEICON,0,LPARAM(ActionItem.szNameID));
ActionItem.hIcolibIcon :=0;
ActionItem.hIcolibIconPressed:=0;
end;
//===== Really places =====
//----- Hotkeys -----
function AddCoreHotkey(var ActionItem:tMyActionItem):boolean;
var
hkd:THOTKEYDESC;
begin
if (ActionItem.flags and UAF_HKREGGED)=0 then
begin
FillChar(hkd,SizeOf(hkd),0);
hkd.cbSize := SizeOf(hkd); // HOTKEYDESC_SIZE_V1 for pre-0.9
hkd.dwFlags := HKD_UNICODE; // since 0.9 only
hkd.pszName := ActionItem.szNameID;
hkd.pszDescription.w:= ActionItem.szActDescr;
hkd.pszSection .w:= MODULE_NAME;
hkd.pszService := SERVICE_WITH_LPARAM_NAME;
hkd.lParam := ActionItem.dwActID;
result:=Hotkey_Register(@hkd)<>0;
if result then
ActionItem.flags:=ActionItem.flags or UAF_HKREGGED;
end
else
result:=true; //!!
end;
procedure DeleteCoreHotkey(var ActionItem:tMyActionItem);
begin
if // bCoreHotkeyPresents and
// (ServiceExists(MS_HOTKEY_UNREGISTER)<>0) and
((ActionItem.flags and UAF_HKREGGED)<>0) then
begin
CallService(MS_HOTKEY_UNREGISTER,0,LParam(ActionItem.szNameID));
ActionItem.flags:=ActionItem.flags and not UAF_HKREGGED;
end;
end;
//----- Common menu functions -----
function AddRootMenuIcon(szPopupName:pWideChar):THANDLE;
var
sid:TSKINICONDESC;
begin
FillChar(sid,SizeOf(sid),0);
//first - register icon for root popup
sid.cbSize := sizeof(sid);
sid.szSection.w := ICOLIB_MNUSECTION;
sid.flags := SIDF_ALL_UNICODE;
sid.cx := 16;
sid.cy := 16;
sid.szDescription.w:= szPopupName;
sid.szDefaultFile.w:= szMyPath;
sid.iDefaultIndex := -IDI_ACTION;
WideToAnsi(szPopupName,sid.pszName);
result:=Skin_AddIcon(@sid);
mFreeMem(sid.pszName);
end;
procedure DeleteMenuItem(var ActionItem:tMyActionItem;mtype:tMenuType);
var
i:integer;
hMenuRoot:THANDLE;
p:pMyActionItem;
begin
with ActionItem.UAMenuItem[mtype] do
begin
if hMenuItem=0 then exit;
CallService(MO_REMOVEMENUITEM,hMenuItem,0);
hMenuItem:=0;
end;
hMenuRoot:=ActionItem.UAMenuItem[mtype].hMenuRoot;
if hMenuRoot<>0 then
begin
for i:=0 to HIGH(UActionList) do
begin
p:=@UActionList[i];
// presents somethere else
if (p<>@ActionItem) and (p.UAMenuItem[mtype].hMenuRoot=hMenuRoot) then
exit;
end;
// menu array cleanup now?
for i:=0 to HIGH(arMenuRec) do
begin
if arMenuRec[i][mtype].hMenuRoot=hMenuRoot then
begin
FillChar(arMenuRec[i][mtype],SizeOf(tuaMenuRec),0);
// arMenuRec[i][mtype].hMenuRoot:=0;
break;
end;
end;
CallService(MO_REMOVEMENUITEM,hMenuRoot,0);
ActionItem.UAMenuItem[mtype].hMenuRoot:=0;
end;
end;
function GetMenuPosition(hMenu:HMENU;mtype:tMenuType;toset:boolean):integer;
var
i:integer;
begin
result:=0;
for i:=0 to HIGH(arMenuRec) do
begin
if arMenuRec[i][mtype].hMenuRoot=hMenu then
begin
if toset then
inc(arMenuRec[i][mtype].position,100000);
result:=arMenuRec[i][mtype].position;
break;
end;
end;
end;
function MakeMenuItem(mtype:tMenuType;clmi:PCListMenuItem):THANDLE;
begin
case mtype of
main_menu : result:=Menu_AddMainMenuItem(clmi);
contact_menu: result:=Menu_AddContactMenuItem(clmi);
tray_menu : result:=Menu_AddTrayMenuItem(clmi);
proto_menu : result:=Menu_AddProtoMenuItem(clmi);
status_menu : result:=Menu_AddStatusMenuItem(clmi);
else
result:=0;
end;
end;
procedure CreateMenuItem(var ActionItem:tMyActionItem;mtype:tMenuType);
var
i:integer;
ActItem:pMyActionItem;
ActMItem,UAMenuItem:pUAMenuItem;
clmi:TCListMenuItem;
res:boolean;
extra:pWideChar;
begin
{}
UAMenuItem:=@ActionItem.UAMenuItem[mtype];
if UAMenuItem.hMenuItem<>0 then exit;
// create popup menu
{}{}
res:=true;
if (UAMenuItem.szMenuPopup<>nil) and (UAMenuItem.szMenuPopup^<>#0) then
begin
res:=false;
for i:=0 to HIGH(UActionList) do
begin
// try to find root popup with same name (if we already created one)
ActItem :=@UActionList[i];
ActMItem:=@ActItem.UAMenuItem[mtype];
if (ActMItem.szMenuPopup<>nil) and
(ActMItem.hMenuRoot<>0) and
( (ActItem<>@ActionItem) and
(StrCmpW(ActMItem.szMenuPopup,UAMenuItem.szMenuPopup)=0) ) then
begin
UAMenuItem.hMenuRoot:=ActMItem.hMenuRoot;
res:=true;
break;
end;
end;
end;
// popup menu not found
if not res then
begin
FillChar(clmi,SizeOf(clmi),0);
clmi.cbSize:=SizeOf(clmi);
clmi.flags :=CMIF_UNICODE{ or CMIF_ICONFROMICOLIB};
if (UAMenuItem.szMenuPopup<>nil) and (UAMenuItem.szMenuPopup^<>#0) then
clmi.szName.w:=ParseVarString(UAMenuItem.szMenuPopup)
else
clmi.szName.w:=ActionItem.szActDescr;
clmi.hIcon :=AddRootMenuIcon(clmi.szName.w);
clmi.position:=ActionItem.wSortIndex*10;
// position in Root Menu
inc(clmi.position,GetMenuPosition(0,mtype,
(UAMenuItem.menu_opt and UAF_MENUSEP)<>0));
UAMenuItem.hMenuRoot:=MakeMenuItem(mtype,@clmi);
//CallService(MenuServices[mtype],0,LPARAM(@clmi));
if clmi.szName.w<>ActionItem.szActDescr then
mFreeMem(clmi.szName.w);
for i:=1 to HIGH(arMenuRec) do
begin
with arMenuRec[i][mtype] do
if hMenuRoot=0 then
begin
// MenuName :=ActionItem.szActDescr;
hMenuRoot:=UAMenuItem.hMenuRoot;
break;
end;
end;
end;
{}{}
// Now Menu Item preparing
{}{}
FillChar(clmi,SizeOf(clmi),0);
clmi.cbSize:=SizeOf(clmi);
clmi.flags:=CMIF_UNICODE{ or CMIF_ICONFROMICOLIB};
if (ActionItem.flags and (UAF_2STATE+UAF_PRESSED))<>(UAF_2STATE+UAF_PRESSED) then
begin
clmi.hIcon:=ActionItem.hIcolibIcon;
extra:='0';
end
else
begin
clmi.hIcon:=ActionItem.hIcolibIconPressed;
clmi.flags:=CMIF_UNICODE {or CMIF_ICONFROMICOLIB }or CMIF_CHECKED;
extra:='1';
end;
with ActionItem.UAMenuItem[mtype] do
begin
if (szMenuNameVars<>nil) and (szMenuNameVars^<>#0) then
clmi.szName.w:=ParseVarString(szMenuNameVars,0,extra)
else
clmi.szName.w:=ActionItem.szActDescr;
if hMenuRoot<>0 then
begin
clmi.flags:=clmi.flags or CMIF_ROOTHANDLE;
clmi.szPopupName.w:=pWideChar(hMenuRoot);
end;
end;
clmi.pszService:=ActionItem.szNameID;
if ActionItem.hMenuService=0 then
ActionItem.hMenuService:=CreateServiceFunctionParam(
clmi.pszService,@ServiceCallWithFParam,ActionItem.dwActID);
clmi.position:=ActionItem.wSortIndex*10;
{}{}
inc(clmi.position,GetMenuPosition(UAMenuItem.hMenuRoot,mtype,
(UAMenuItem.menu_opt and UAF_MENUSEP)<>0));
UAMenuItem.hMenuItem:=MakeMenuItem(mtype,@clmi);
//CallService(MenuServices[mtype],0,LPARAM(@clmi));
if clmi.szName.w<>ActionItem.szActDescr then
mFreeMem(clmi.szName.w);
{}
end;
function PreBuildMenu(mtype:tMenuType;hContact:THANDLE=0):int;
var
i:integer;
mi:TCListMenuItem;
p,extra:pWideChar;
begin
result:=0;
FillChar(mi,SizeOf(mi),0);
mi.cbSize:=SizeOf(mi);
for i:=0 to HIGH(UActionList) do
begin
mi.flags:=CMIM_FLAGS;
p:=nil;
with UActionList[i] do
begin
with UAMenuItem[mtype] do
begin
if hMenuItem<>0 then // it means, we process that item here
begin
mi.szName.w:=nil;
// Show / hide
if isVarsInstalled then
begin
if (szMenuShowWhenVars<>nil) and (szMenuShowWhenVars^<>#0) then
begin
p:=ParseVarString(szMenuShowWhenVars,hContact);
if p<>nil then
begin
if StrCmpW(p,'1')<>0 then
mi.flags:=CMIM_FLAGS or CMIF_HIDDEN;
mFreeMem(p);
end;
end;
end;
// change if need to show only
// (popup can be used by many items, keep unchanged)
if (mi.flags and CMIF_HIDDEN)=0 then
begin
//!!!! icon (check for contact menu)
mi.flags:=mi.flags or CMIM_ICON or CMIM_FLAGS{ or CMIF_ICONFROMICOLIB};
if (mtype=contact_menu) and IsLocalItem(UActionList[i]) then
begin
lastContact:=hContact;
if ((flags and UAF_2STATE)<>0) and
(DBReadByte(hContact,opt_ua,szNameID)<>0) then
begin
mi.flags:=mi.flags or CMIF_CHECKED;
mi.hIcon:=hIcolibIconPressed;
extra:='1';
flags:=flags or UAF_PRESSED;
end
else
begin
mi.hIcon:=hIcolibIcon;
flags:=flags and not UAF_PRESSED;
extra:='0';
end;
end
else
begin
if (flags and (UAF_2STATE+UAF_PRESSED))=(UAF_2STATE+UAF_PRESSED) then
begin
mi.flags:=mi.flags or CMIF_CHECKED;
mi.hIcon:=hIcolibIconPressed;
extra:='1';
end
else
begin
mi.hIcon:=hIcolibIcon;
extra:='0';
end;
end;
// new name
mi.flags:=mi.flags or CMIM_NAME or CMIF_UNICODE;
if (szMenuNameVars<>nil) and (szMenuNameVars^<>#0) then
mi.szName.w:=ParseVarString(szMenuNameVars,hContact,extra);
if mi.szName.w=nil then
mi.szName.w:=szActDescr;
end;
CallService(MS_CLIST_MODIFYMENUITEM,hMenuItem,LPARAM(@mi));
if mi.szName.w<>szActDescr then
mFreeMem(mi.szName.w);
end;
end;
end;
end;
end;
function PreBuildMainMenu(wParam:WPARAM;lParam:LPARAM):int; cdecl;
begin
result:=PreBuildMenu(main_menu,wParam);
end;
function PreBuildContactMenu(wParam:WPARAM;lParam:LPARAM):int; cdecl;
begin
result:=PreBuildMenu(contact_menu,wParam);
end;
function PreBuildTrayMenu(wParam:WPARAM;lParam:LPARAM):int; cdecl;
begin
result:=PreBuildMenu(tray_menu,wParam);
end;
//----- TopToolbar -----
procedure AddTTBButton(var ActionItem:tMyActionItem);
var
mtButton:TTBButton;
pc,pc1,pc2:pAnsiChar;
res:boolean;
p:pWideChar;
begin
if not NamesArray[uaTTB].enable then exit;
if ActionItem.hTTBButton=0 then
begin
// Add or not
if isVarsInstalled then
begin
if (ActionItem.szTTBShowWhenVars<>nil) and (ActionItem.szTTBShowWhenVars^<>#0) then
begin
p:=ParseVarString(ActionItem.szTTBShowWhenVars);
if p<>nil then
begin
res:=StrCmpW(p,'1')<>0;
mFreeMem(p);
end
else
res:=true;
if res then
exit;
end;
end;
FillChar(mtButton,SizeOf(mtButton),0);
mtButton.cbSize :=SizeOf(mtButton);
mtButton.pszService:=TTB_SERVICE_NAME;//SERVICE_WITH_LPARAM_NAME;
mtButton.lParamUp :=ActionItem.dwActID;
mtButton.lParamDown:=ActionItem.dwActID;
mtButton.hIconUp:=ActionItem.hIcolibIcon;
mtButton.hIconDn:=ActionItem.hIcolibIconPressed;
WideToAnsi(ActionItem.szActDescr,pc);
if (ActionItem.flags and UAF_2STATE)<>0 then
mtButton.dwFlags:=TTBBF_VISIBLE or TTBBF_SHOWTOOLTIP{ or TTBBF_ASPUSHBUTTON}
else
mtButton.dwFlags:=TTBBF_VISIBLE or TTBBF_SHOWTOOLTIP;
if ActionItem.szTTBTooltip =nil then
pc1:=pc
else pc1:=ActionItem.szTTBTooltip;
if ((ActionItem.flags and UAF_2STATE)=0) or
(ActionItem.szTTBTooltipPressed=nil) then
pc2:=pc1
else
pc2:=ActionItem.szTTBTooltipPressed;
mtButton.Name :=pc;
mtButton.pszTooltipUp :=pc1;
mtButton.pszTooltipDn :=pc2;
ActionItem.hTTBButton:=TopToolbar_AddButton(@mtButton);
if ActionItem.hTTBButton=THANDLE(-1) then
ActionItem.hTTBButton:=0;
mFreeMem(pc);
end;
end;
procedure DeleteTTBButton(var ActionItem:tMyActionItem);
begin
if ActionItem.hTTBButton<>0 then
begin
CallService(MS_TTB_REMOVEBUTTON,ActionItem.hTTBButton,0);
ActionItem.hTTBButton:=0;
end;
end;
function TTBServiceCall(wParam:WPARAM; lParam:LPARAM):int_ptr; cdecl;
var
i,lflag:integer;
begin
result:=0;
for i:=0 to HIGH(UActionList) do
begin
if TLPARAM(UActionList[i].dwActID)=lParam then
begin
with UActionList[i] do
begin
if (flags and UAF_2STATE)<>0 then
begin
if CallService(MS_TTB_GETBUTTONSTATE,hTTBButton,0)=TTBST_PUSHED then
begin
lflag:=TTBST_RELEASED;
end
else
begin
lflag:=TTBST_PUSHED;
end;
CallService(MS_TTB_SETBUTTONSTATE,hTTBButton,lflag);
end;
end;
result:=ServiceCallWithFParam(0,0,lParam);
break;
end;
end;
end;
function OnTTBLoaded(wParam:WPARAM;lParam:LPARAM):int; cdecl;
var
i:integer;
begin
result:=0;
for i:=HIGH(UActionList) downto 0 do
begin
if (UActionList[i].flags and UAF_REGTTBB)<>0 then
AddTTBButton(UActionList[i]);
end;
end;
//----- TabSRMM Toolbar -----
const
TABTOOLBAR_INITPOS = 350;
procedure AddTabBBButton(var ActionItem:tMyActionItem);
var
tabb:BBButton;
begin
if not NamesArray[uaTAB].enable then exit;
if (ActionItem.flags and UAF_TBREGGED)=0 then
begin
FillChar(tabb,SizeOf(tabb),0);
// register Tab ButtonBar button
tabb.cbSize :=SizeOf(tabb);
tabb.dwButtonID :=ActionItem.dwActID;
tabb.pszModuleName:=MODULE_NAME;
tabb.dwDefPos :=(TABTOOLBAR_INITPOS+ActionItem.wSortIndex*10) and $7FFF;
tabb.iButtonWidth :=0;
tabb.hIcon :=ActionItem.hIcolibIcon;
if (ActionItem.flags and UAF_2STATE)<>0 then
tabb.bbbFlags:=BBBF_ISIMBUTTON or BBBF_ISLSIDEBUTTON or
BBBF_ISCHATBUTTON or BBBF_ISPUSHBUTTON
else
tabb.bbbFlags:=BBBF_ISIMBUTTON or BBBF_ISLSIDEBUTTON or
BBBF_ISCHATBUTTON;
if ActionItem.szTabBTooltip<>nil then
tabb.szTooltip.w:=ActionItem.szTabBTooltip
else
tabb.szTooltip.w:=ActionItem.szActDescr;
if CallService(MS_BB_ADDBUTTON,0,LPARAM(@tabb))=0 then
ActionItem.flags:=ActionItem.flags or UAF_TBREGGED;
end;
end;
procedure DeleteTabBBButton(var ActionItem:tMyActionItem);
var
tabb:BBButton;
begin
if (ActionItem.flags and UAF_TBREGGED)<>0 then
begin
FillChar(tabb,SizeOf(tabb),0);
tabb.cbSize :=SizeOf(tabb);
tabb.dwButtonID :=ActionItem.dwActID;
tabb.pszModuleName:=MODULE_NAME;
CallService(MS_BB_REMOVEBUTTON,0,LPARAM(@tabb));
ActionItem.flags:=ActionItem.flags and not UAF_TBREGGED;
end;
end;
function OnTabButtonPressed(wParam:WPARAM;lParam:LPARAM):int; cdecl;
var
cbcd:pCustomButtonClickData;
// tabb:BBButton;
// pc:pWideChar;
i:integer;
begin
result:=0;
cbcd:=pointer(lParam);
if StrCmp(cbcd.pszModule,MODULE_NAME)<>0 then
exit;
for i:=0 to HIGH(UActionList) do
begin
with UActionList[i] do
begin
if cbcd.dwButtonId=dwActID then
begin
{
FillChar(tabb,SizeOf(tabb),0);
tabb.cbSize :=SizeOf(tabb);
tabb.dwButtonID :=cbcd.dwButtonId;
tabb.pszModuleName:=MODULE_NAME;
if (flags and UAF_2STATE)<>0 then
begin
CallService(MS_BB_GETBUTTONSTATE,cbcd.hContact,TLPARAM(@tabb));
if IsLocalItem(UActionList[i]) then
begin
if DBReadByte(hContact,opt_ua,szNameID)<>0 then
end
else
begin
if (tabb.bbbFlags and BBSF_PUSHED)<>0 then
begin
pc:=szTabBTooltipPressed;
if pc=nil then pc:=szTabBTooltip;
tabb.hIcon:=hIcolibIconPressed;
end
else
begin
pc:=szTabBTooltip;
tabb.hIcon:=hIcolibIcon;
end;
if pc=nil then pc:=szActDescr;
tabb.szTooltip.w:=pc;
tabb.bbbFlags :=BBBF_ISIMBUTTON or BBBF_ISLSIDEBUTTON or
BBBF_ISCHATBUTTON or BBBF_ISPUSHBUTTON;
end
else
begin
tabb.hIcon:=hIcolibIcon;
tabb.szTooltip.w:=szTabBTooltip;
if tabb.szTooltip.w=nil then tabb.szTooltip.w:=szActDescr;
tabb.bbbFlags :=BBBF_ISIMBUTTON or BBBF_ISLSIDEBUTTON or
BBBF_ISCHATBUTTON;
end;
tabb.iButtonWidth:=0;
tabb.dwDefPos :=(TABTOOLBAR_INITPOS+wSortIndex*10) and $7FFF;
CallService(MS_BB_MODIFYBUTTON,0,TLPARAM(@tabb));
}
ServiceCallWithFParam(cbcd.hContact,0,cbcd.dwButtonId);
result:=1;
break;
end;
end;
end;
end;
function OnTabBBLoaded(wParam:WPARAM;lParam:LPARAM):int; cdecl;
var
i:integer;
begin
result:=0;
for i:=HIGH(UActionList) downto 0 do
begin
if (UActionList[i].flags and UAF_REGTABB)<>0 then
AddTabBBButton(UActionList[i]);
end;
end;
|