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
|
-
|
-
-
|
-
|
|
|
|
|
-
|
!
!
!
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
!
-
-
|
|
!
!
-
|
-
|
|
!
|
!
-
|
|
|
|
-
|
|
|
|
-
|
!
!
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
-
|
|
!
|
|
|
!
-
|
|
|
|
|
|
!
-
|
-
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
!
-
|
|
|
|
|
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
!
!
-
|
-
|
-
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
-
|
-
|
!
!
|
|
|
|
|
|
|
|
|
-
|
|
-
|
|
|
|
|
|
|
|
-
|
!
!
|
|
|
|
|
-
|
|
-
-
-
|
|
|
!
-
|
!
|
|
-
|
|
|
|
|
|
|
-
|
|
!
|
|
|
|
|
|
|
|
-
|
!
!
|
|
-
-
-
|
|
|
|
|
|
|
-
|
|
!
!
!
|
|
-
-
|
|
|
|
-
|
!
!
|
|
-
|
|
|
|
|
|
|
|
-
|
!
|
|
|
-
|
|
!
|
|
|
|
|
!
|
!
-
|
|
-
|
-
|
-
|
!
-
-
|
-
|
|
|
|
|
|
!
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
!
!
|
!
-
|
|
-
|
-
|
-
|
!
-
-
|
|
|
!
!
|
!
-
|
|
|
!
|
#ifdef __hsp30__
#ifndef __OWNERDRAW_BUTTON__
#define global __OWNERDRAW_BUTTON__
#module "_OD_BUTTON_"
#uselib "gdi32.dll"
#func _BitBlt "BitBlt" int, int, int, int, int, int, int, int, int #func _CombineRgn "CombineRgn" int, int, int, int #cfunc _CreateCompatibleBitmap "CreateCompatibleBitmap" int, int, int #cfunc _CreateCompatibleDC "CreateCompatibleDC" int #cfunc _CreateEllipticRgn "CreateEllipticRgn" int, int, int, int #cfunc _CreateFontIndirect "CreateFontIndirectA" int #cfunc _CreatePatternBrush "CreatePatternBrush" int #cfunc _CreatePen "CreatePen" int, int, int #cfunc _CreatePolygonRgn "CreatePolygonRgn" int, int, int #cfunc _CreateRectRgn "CreateRectRgn" int, int, int, int #cfunc _CreateSolidBrush "CreateSolidBrush" int #func _DeleteDC "DeleteDC" int #func _DeleteObject "DeleteObject" int #cfunc _ExtCreateRegion "ExtCreateRegion" int, int, int #func _FillRgn "FillRgn" int, int, int #func _FrameRgn "FrameRgn" int, int, int, int, int #cfunc _GetCurrentObject "GetCurrentObject" int, int #func _GetObject "GetObjectA" int, int, int #func _GetRegionData "GetRegionData" int, int, int #func _GetRgnBox "GetRgnBox" int, int #cfunc _GetStockObject "GetStockObject" int #func _SelectObject "SelectObject" int, int #func _SetBkMode "SetBkMode" int, int #func _SetPixelV "SetPixelV" int, int, int, int #func _SetROP2 "SetROP2" int, int #func _SetTextColor "SetTextColor" int, int
#uselib "user32.dll"
#func _CharUpper "CharUpperA" int #func _ClientToScreen "ClientToScreen" int, int #func _CreateWindowEx "CreateWindowExA" int, int, int, int, int, int, int, int, int, int, int, int
#func _DestroyWindow "DestroyWindow" int #func _DrawEdge "DrawEdge" int, int, int, int #func _DrawFocusRect "DrawFocusRect" int, int #func _DrawText "DrawTextA" int, int, int, int, int #func _FillRect "FillRect" int, int, int #func _GetClassInfoEx "GetClassInfoExA" int, int, int #func _GetClassName "GetClassNameA" int, int, int
#cfunc _GetDC "GetDC" int #cfunc _GetSysColorBrush "GetSysColorBrush" int #func _GetWindowLong "GetWindowLongA" int, int #func _GetWindowRect "GetWindowRect" int, int #func _GetWindowText "GetWindowTextA" int, int, int #func _GetWindowTextLength "GetWindowTextLengthA" int #func _InvalidateRect "InvalidateRect" int, int, int #func _MoveWindow "MoveWindow" int, int, int, int, int, int #func _RegisterClassEx "RegisterClassExA" int #func _ReleaseDC "ReleaseDC" int, int #func _ScreenToClient "ScreenToClient" int, int #func _SetWindowLong "SetWindowLongA" int, int, int
#func _SetWindowRgn "SetWindowRgn" int, int, int #func _SetWindowText "SetWindowTextA" int, int #func _ShowWindow "ShowWindow" int, int
#defcfunc dbl2sng@_OD_BUTTON_ double _p1
dbl=_p1
sng=0
sgnf=(peek(dbl, 7)>>7) & 0x01
dexp=(((peek(dbl, 7)<<4) & 0x7F0) | (((peek(dbl, 6)>>4) & 0x00F)))
if (dexp=0) & ((lpeek(dbl,1) & 0x000FFFFF)=0) & ((lpeek(dbl,0) & 0xE0000000)=0) {
sng=0
} else {
if (dexp-0x3FF)>=128 {
sng=(sgnf<<31) | (0xFF<<23)
} else {
sexp=(((dexp-0x3FF) & 0xFF)+0x7F) & 0xFF
poke sng, 3, (sgnf<<7) | ((sexp>>1) & 0x7F)
poke sng, 2, ((sexp<<7) & 0x80) | ((peek(dbl, 6)<<3) & 0x78) | ((peek(dbl, 5)>>5) & 0x07)
poke sng, 1, ((peek(dbl, 5)<<3) & 0xF8) | ((peek(dbl, 4)>>5) & 0x07)
poke sng, 0, ((peek(dbl, 4)<<3) & 0xF8) | ((peek(dbl, 3)>>5) & 0x07)
if (dexp-0x3FF)<=-127 {
lpoke sng, 0, (sgnf<<31) | (((lpeek(sng, 0) & 0x007FFFFF) | 0x00800000)>>abs(dexp-0x3FF+126))
}
}
}
return sng
#deffunc setobjinfo@_OD_BUTTON_ int _p1, int _p2, int _p3
mref BMSCRtmp, 67
if BMSCRtmp(72)=0 : return -1 dupptr OBJINFOtmp, BMSCRtmp(71)+12*4*(_p1 & 0xFFFF), 48, 4 if OBJINFOtmp(2)=0 : return -1 OBJINFOtmp(_p2)=_p3
return 0
#define global custombutton(%1=0, %2=-1, %3=0, %4=0, %5=0x17, %6=-16, %7=0, %8=0, %9=0x17, %10=0) \
_customizebutton@_OD_BUTTON_ %1, %2, %3, %4, %5, %6, %7, %8, %9, 0x2000, %10
#define global custombuttonBG(%1=0, %2=-1, %3=0, %4=0, %5=0x17, %6=-16, %7=0, %8=0, %9=0x17, %10=0) \
_customizebutton@_OD_BUTTON_ %1, %2, %3, %4, %5, %6, %7, %8, %9, 0x1800, %10
#define global custombuttonBG2(%1=0, %2=-1, %3=0, %4=0, %5=0x17, %6=-16, %7=0, %8=0, %9=0x17, %10=0) \
_customizebutton@_OD_BUTTON_ %1, %2, %3, %4, %5, %6, %7, %8, %9, 0x1000, %10
#define global picturebutton(%1=0, %2=-1, %3=0, %4=0, %5=0x17, %6=-16, %7=0, %8=0, %9=0x17, %10=0) \
_customizebutton@_OD_BUTTON_ %1, %2, %3, %4, %5, %6, %7, %8, %9, 0x1800, %10
#define CustomBtnidlimit 32
#deffunc _customizebutton@_OD_BUTTON_ \
int _p1, int _p2, int _p3,int _p4, int _p5, int _p6, int _p7, int _p8, int _p9, int _p10, int _p11
if initcustomizebutton=0 {
initcustomizebutton=1
dim CustomBtnInfo, 20, CustomBtnidlimit
dim CustomBtnInfoTmp, 4
dim syscrFrame, 4 dim rectTmp, 4
dim hRgnTmp, 4
dim XFORM, 6
dim LOGFONT, 15
sdim classname, 64
sdim newclassname, 64
sdim textBtn, 256
mref BMSCR, 96
hdcFrame=_CreateCompatibleDC(BMSCR(4))
hbmFrame=_CreateCompatibleBitmap(BMSCR(4), 8, 8)
_SelectObject hdcFrame, hbmFrame
rectTmp=0, 0, 8, 8
_FillRect hdcFrame, varptr(rectTmp), _GetStockObject(4)
repeat 4
i=cnt
repeat 4
_setPixelV hdcFrame, cnt*2, i*2, 0xFFFFFF
_setPixelV hdcFrame, cnt*2+1, i*2+1, 0xFFFFFF
loop
loop
_DeleteDC hdcFrame
dim WNDCLASSEX, 12
classname="Button"
_GetClassInfoEx hinstance, varptr(classname), varptr(WNDCLASSEX)
newclassname="HSP3_CustomButton"
WNDCLASSEX(0)=48
WNDCLASSEX(1)=WNDCLASSEX(1) & 0xFFFFFFF7 WNDCLASSEX(10)=varptr(newclassname)
_RegisterClassEx varptr(WNDCLASSEX)
}
CustomBtnid=-1
repeat CustomBtnidlimit
if CustomBtnInfo(0, cnt) ! 0 {
if CustomBtnInfo(0, cnt)=objInfo(_p1, 2) { CustomBtnid=cnt
break
}
}
loop
if CustomBtnid=-1 { repeat CustomBtnidlimit
if CustomBtnInfo(0, cnt)=0 {
CustomBtnid=cnt
break
}
loop
}
if CustomBtnid=-1 : return -1
CustomBtnInfo(0, CustomBtnid)=objInfo(_p1,2)
_GetClassName CustomBtnInfo(0, CustomBtnid), varptr(classname), 63
_CharUpper varptr(classname)
if classname!"BUTTON" & classname!"HSP3_CUSTOMBUTTON" : CustomBtnInfo(0, CustomBtnid)=0 : return -1
_GetWindowLong CustomBtnInfo(0, CustomBtnid), -16
if ((stat & 0x000F) ! 0x0000) & ((stat & 0x000F) ! 0x000B) : CustomBtnInfo(0, CustomBtnid)=0 : return -1
CustomBtnInfo(1, CustomBtnid)=_p1
CustomBtnInfo(2, CustomBtnid)=_p2
CustomBtnInfo(3, CustomBtnid)=_p3
CustomBtnInfo(4, CustomBtnid)=_p4
CustomBtnInfo(5, CustomBtnid)=_p5
if _p6=-16 {
CustomBtnInfo(6, CustomBtnid)=_p2
CustomBtnInfo(7, CustomBtnid)=_p3
CustomBtnInfo(8, CustomBtnid)=_p4
CustomBtnInfo(9, CustomBtnid)=_p5
} else {
CustomBtnInfo(6, CustomBtnid)=_p6
CustomBtnInfo(7, CustomBtnid)=_p7
CustomBtnInfo(8, CustomBtnid)=_p8
CustomBtnInfo(9, CustomBtnid)=_p9
if (_p5 & 0x0000F000) ! (_p9 & 0x0000F000) {
CustomBtnInfo(9, CustomBtnid)=(CustomBtnInfo(9, CustomBtnid) & 0xFFFF0FFF) | (_p5 & 0x0000F000)
}
}
CustomBtnInfo(10, CustomBtnid)=ginfo(3) CustomBtnInfo(11, CustomBtnid)=_p10 CustomBtnInfo(12, CustomBtnid)=(ginfo(18)<<16) | (ginfo(17)<<8) | ginfo(16)
if CustomBtnInfo(14, CustomBtnid)=0 {
oldhWnd=CustomBtnInfo(0, CustomBtnid)
_ShowWindow oldhWnd, 0
_GetWindowLong oldhWnd, -12
oldChildid=stat
_SetWindowLong oldhWnd, -12, (oldChildid<<16)
_GetWindowRect oldhwnd, varptr(rectTmp)
_ScreenToClient hwnd, varptr(rectTmp(0))
_ScreenToClient hwnd, varptr(rectTmp(2))
textBtn=""
_GetWindowTextLength oldhwnd
if stat ! 0 : _GetWindowText oldhwnd, varptr(textBtn), limit(stat+1, 0, 255)
_CreateWindowEx 0, varptr(newclassname), varptr(textBtn), 0x50000000, rectTmp(0), rectTmp(1), rectTmp(2)-rectTmp(0), rectTmp(3)-rectTmp(1), hwnd, oldChildid, hinstance, 0
CustomBtnInfo( 0, CustomBtnid)=stat
mref BMSCR, 67
if BMSCR(48)=2 { _GetObject BMSCR(38), 60, varptr(LOGFONT)
hFont=_CreateFontIndirect(varptr(LOGFONT))
CustomBtnInfo(13, CustomBtnid)=hFont
} else : if BMSCR(48)=1 {
CustomBtnInfo(13, CustomBtnid)=0
hFont=_GetStockObject(17)
} else { CustomBtnInfo(13, CustomBtnid)=0
hFont=_GetStockObject(13)
}
sendmsg CustomBtnInfo(0, CustomBtnid), 0x30, hFont, 1
setobjinfo CustomBtnInfo(1, CustomBtnid), 2, CustomBtnInfo(0, CustomBtnid)
CustomBtnInfo(14, CustomBtnid)=oldhWnd
}
if CustomBtnInfo(15, CustomBtnid) ! 0 { _SetWindowRgn CustomBtnInfo(0, CustomBtnid), 0, 0
if CustomBtnInfo(16, CustomBtnid) ! 0 : _DeleteObject CustomBtnInfo(16, CustomBtnid)
if CustomBtnInfo(17, CustomBtnid) ! 0 : _DeleteObject CustomBtnInfo(17, CustomBtnid)
if CustomBtnInfo(18, CustomBtnid) ! 0 : _DeleteObject CustomBtnInfo(18, CustomBtnid)
if CustomBtnInfo(19, CustomBtnid) ! 0 : _DeleteObject CustomBtnInfo(19, CustomBtnid)
}
CustomBtnInfo(15, CustomBtnid)=0, 0, 0, 0, 0
_GetWindowRect CustomBtnInfo(0, CustomBtnid), varptr(rectTmp)
if ((_p5>>12) & 0xF)=15 { CustomBtnInfo(15, CustomBtnid)=_p11
} else : if ((_p5>>12) & 0xF)=1 { CustomBtnInfo(15, CustomBtnid)=_CreateEllipticRgn(0, 0, rectTmp(2)-rectTmp(0), rectTmp(3)-rectTmp(1))
} else : if ((_p5>>12) & 0xF)=4 { dim point, 2, 3
point(0, 0)=(rectTmp(2)-rectTmp(0))/2, 0
point(0, 1)=0, rectTmp(3)-rectTmp(1)
point(0, 2)=rectTmp(2)-rectTmp(0), rectTmp(3)-rectTmp(1)
CustomBtnInfo(15, CustomBtnid)=_CreatePolygonRgn(varptr(point), 3, 2) } else : if ((_p5>>12) & 0xF)=5 { dim point, 2, 3
point(0, 0)=0, 0
point(0, 1)=rectTmp(2)-rectTmp(0), 0
point(0, 2)=(rectTmp(2)-rectTmp(0))/2, rectTmp(3)-rectTmp(1)
CustomBtnInfo(15, CustomBtnid)=_CreatePolygonRgn(varptr(point), 3, 2) } else : if ((_p5>>12) & 0xF)=6 { dim point, 2, 3
point(0, 0)=0, (rectTmp(3)-rectTmp(1))/2
point(0, 1)=rectTmp(2)-rectTmp(0), 0
point(0, 2)=rectTmp(2)-rectTmp(0), rectTmp(3)-rectTmp(1)
CustomBtnInfo(15, CustomBtnid)=_CreatePolygonRgn(varptr(point), 3, 2) } else : if ((_p5>>12) & 0xF)=7 { dim point, 2, 3
point(0, 0)=0, 0
point(0, 1)=rectTmp(2)-rectTmp(0), (rectTmp(3)-rectTmp(1))/2
point(0, 2)=0, rectTmp(3)-rectTmp(1)
CustomBtnInfo(15, CustomBtnid)=_CreatePolygonRgn(varptr(point), 3, 2) } else : if ((_p5>>12) & 0xF)=8 { dim point, 2, 5
point(0, 0)=(rectTmp(2)-rectTmp(0))/2, 0
point(0, 1)=int(0.8632712640026804*(rectTmp(2)-rectTmp(0))), rectTmp(3)-rectTmp(1)
point(0, 2)=0, int(0.3375401518835469*(rectTmp(3)-rectTmp(1)))
point(0, 3)=rectTmp(2)-rectTmp(0), int(0.3375401518835469*(rectTmp(3)-rectTmp(1)))
point(0, 4)=int(0.1367287359973196*(rectTmp(2)-rectTmp(0))), rectTmp(3)-rectTmp(1)
CustomBtnInfo(15, CustomBtnid)=_CreatePolygonRgn(varptr(point), 5, 2) } else { CustomBtnInfo(15, CustomBtnid)=0 }
if CustomBtnInfo(15, CustomBtnid) ! 0 {
CustomBtnInfo(16, CustomBtnid)=_CreateRectRgn(0, 0, 0, 0)
_CombineRgn CustomBtnInfo(16, CustomBtnid), CustomBtnInfo(15, CustomBtnid), CustomBtnInfo(15, CustomBtnid), 0x00000005 _GetRegionData CustomBtnInfo(16, CustomBtnid), 0, 0
i=stat
if i ! 0 {
sdim RGNDATA, i
_GetRegionData CustomBtnInfo(16, CustomBtnid), i, varptr(RGNDATA)
repeat 4
j=cnt+1
XFORM(0)=dbl2sng(double(rectTmp(2)-rectTmp(0)-j*2)/double(rectTmp(2)-rectTmp(0)))
XFORM(1)=0
XFORM(2)=0
XFORM(3)=dbl2sng(double(rectTmp(3)-rectTmp(1)-j*2)/double(rectTmp(3)-rectTmp(1)))
XFORM(4)=dbl2sng(double(j))
XFORM(5)=dbl2sng(double(j))
hRgnTmp(cnt)=_ExtCreateRegion(varptr(XFORM), i, varptr(RGNDATA))
loop
CustomBtnInfo(17, CustomBtnid)=_CreateRectRgn(0, 0, 0, 0)
_CombineRgn CustomBtnInfo(17, CustomBtnid), CustomBtnInfo(16, CustomBtnid), hRgnTmp(1), 4 CustomBtnInfo(18, CustomBtnid)=_CreateRectRgn(0, 0, 0, 0)
_CombineRgn CustomBtnInfo(18, CustomBtnid), hRgnTmp(0), hRgnTmp(1), 4 CustomBtnInfo(19, CustomBtnid)=_CreateRectRgn(0, 0, 0, 0)
_CombineRgn CustomBtnInfo(19, CustomBtnid), hRgnTmp(2), hRgnTmp(3), 4 repeat 4
_DeleteObject hRgnTmp(cnt)
loop
}
}
_SetWindowRgn CustomBtnInfo(0, CustomBtnid), CustomBtnInfo(15, CustomBtnid), 0
#define WM_DRAWITEM 0x0000002B
oncmd gosub *msg_wmdrawitem@_OD_MESSAGE_, WM_DRAWITEM
sendmsg CustomBtnInfo(0, CustomBtnid), 0x00F4, 0x000B, 1
return CustomBtnid
#deffunc drawitem_odbutton int _p1, int _p2
#enum DIS_CtlType =0 #enum DIS_CtlID #enum DIS_itemID #enum DIS_itemAction #enum DIS_itemState #enum DIS_hwndItem #enum DIS_hDC #enum DIS_rcItem0 #enum DIS_rcItem1 #enum DIS_rcItem2 #enum DIS_rcItem3 #enum DIS_itemData wp=_p1
lp=_p2
rp=0
dupptr DIS, lp, 48, 4
if DIS.DIS_CtlType=4 { repeat CustomBtnidlimit
if DIS.DIS_hwndItem=CustomBtnInfo(0, cnt) {
CustomBtnId=cnt
if (DIS.DIS_itemState & 0x0001)=0 { CustomBtnInfoTmp(0)=CustomBtnInfo(2, CustomBtnid)
CustomBtnInfoTmp(1)=CustomBtnInfo(3, CustomBtnid)
CustomBtnInfoTmp(2)=CustomBtnInfo(4, CustomBtnid)
CustomBtnInfoTmp(3)=CustomBtnInfo(5, CustomBtnid)
stateDE=0x0005 syscrFrame(0)=20
syscrFrame(2)=22
offsetDraw=0
} else {
CustomBtnInfoTmp(0)=CustomBtnInfo(6, CustomBtnid)
CustomBtnInfoTmp(1)=CustomBtnInfo(7, CustomBtnid)
CustomBtnInfoTmp(2)=CustomBtnInfo(8, CustomBtnid)
CustomBtnInfoTmp(3)=CustomBtnInfo(9, CustomBtnid)
stateDE=0x000A syscrFrame(0)=21
syscrFrame(2)=16
if (CustomBtnInfoTmp(3) & 0x0001) ! 0 {
offsetDraw=1
} else {
offsetDraw=0
}
}
hdcButton=_CreateCompatibleDC(DIS.DIS_hDC)
hbmButton=_CreateCompatibleBitmap(DIS.DIS_hDC, DIS.DIS_rcItem2, DIS.DIS_rcItem3)
_SelectObject hdcButton, hbmButton
mref BMSCR, 96+CustomBtnInfo(10, CustomBtnid)
_GetWindowRect DIS.DIS_hwndItem, varptr(rectTmp)
_ScreenToClient BMSCR(13), varptr(rectTmp(0))
if (CustomBtnInfo(11, CustomBtnid) & 0x1000) ! 0 { _Bitblt hdcButton, 0, 0, DIS.DIS_rcItem2, DIS.DIS_rcItem3, BMSCR(4), rectTmp(0), rectTmp(1), 0x00CC0020
} else : if (CustomBtnInfo(11, CustomBtnid) & 0x2000) ! 0 { _GetWindowLong BMSCR(13), -16
oldStyle=stat
_SetWindowLong BMSCR(13), -16, oldStyle | 0x02000000
hdcParent=_GetDC(BMSCR(13))
_Bitblt hdcParent, rectTmp(0), rectTmp(1), DIS.DIS_rcItem2, DIS.DIS_rcItem3, BMSCR(4), rectTmp(0), rectTmp(1), 0x00CC0020
_ReleaseDC BMSCR(13), hdcParent
_SetWindowLong BMSCR(13), -16, oldStyle
if CustomBtnInfoTmp(0)=-2 & CustomBtnInfoTmp(1)=-1 { _Bitblt hdcButton, 0, 0, DIS.DIS_rcItem2, DIS.DIS_rcItem3, BMSCR(4), rectTmp(0), rectTmp(1), 0x00CC0020
}
}
if CustomBtnInfo(16, CustomBtnid) ! 0 : _SelectObject hdcButton, CustomBtnInfo(16, CustomBtnid)
if CustomBtnInfoTmp(0)>=0 { mref BMSCR, 96+CustomBtnInfoTmp(0)
_BitBlt hdcButton, DIS.DIS_rcItem0+offsetDraw, DIS.DIS_rcItem1+offsetDraw, DIS.DIS_rcItem2-DIS.DIS_rcItem0-offsetDraw, DIS.DIS_rcItem3-DIS.DIS_rcItem1-offsetDraw, BMSCR(4), CustomBtnInfoTmp(1), CustomBtnInfoTmp(2), 0x00CC0020
} else : if CustomBtnInfoTmp(0)=-2 { if CustomBtnInfoTmp(1)=-1 {
} else {
hBrush=_CreateSolidBrush( ((CustomBtnInfoTmp(1)<<16) & 0xFF0000) | (CustomBtnInfoTmp(1) & 0x00FF00) | ((CustomBtnInfoTmp(1)>>16) & 0x0000FF) )
_FillRect hdcButton, varptr(DIS.DIS_rcItem0), hBrush
_DeleteObject hBrush
}
} else { _FillRect hdcButton, varptr(DIS.DIS_rcItem0), _GetSysColorBrush(15)
}
if (CustomBtnInfoTmp(3) & 0x0010) ! 0 {
textBtn=""
_GetWindowTextLength DIS.DIS_hwndItem
if stat ! 0 : _GetWindowText DIS.DIS_hwndItem, varptr(textBtn), limit(stat+1, 0, 255)
rectTmp(0)=DIS.DIS_rcItem0+offsetDraw*2
rectTmp(1)=DIS.DIS_rcItem1+offsetDraw*2
rectTmp(2)=DIS.DIS_rcItem2
rectTmp(3)=DIS.DIS_rcItem3-1
if (CustomBtnInfoTmp(3) & 0x0020) ! 0 {
_SetTextColor hdcButton, CustomBtnInfo(12, CustomBtnId)
oldTextColor=stat
}
_SetBkMode hdcButton, 1 oldBkMode=stat
hFont=_GetCurrentObject(DIS.DIS_hDC, 6) _SelectObject hdcButton, hFont
oldFont=stat
_DrawText hdcButton, varptr(textBtn), strlen(textBtn), varptr(rectTmp), 0x0025 _SelectObject hdcButton, oldFont
_SetBkMode hdcButton, oldBkMode
if (CustomBtnInfoTmp(3) & 0x0020) ! 0 {
_SetTextColor hdcButton, oldTextColor
}
}
if (CustomBtnInfoTmp(3) & 0x0004) ! 0 {
if (DIS.DIS_itemState & 0x0010) ! 0 { if CustomBtnInfo(16, CustomBtnid) ! 0 {
_SetROP2 hdcButton, 7 oldROP2=stat
hBrush=_CreatePatternBrush(hbmFrame)
_FillRgn hdcButton, CustomBtnInfo(19, CustomBtnid), hBrush
_SetROP2 hdcButton, oldROP2
_DeleteObject hBrush
} else {
rectTmp=3, 3, DIS.DIS_rcItem2-3, DIS.DIS_rcItem3-3
_DrawFocusRect hdcButton, varptr(rectTmp)
}
}
}
if (CustomBtnInfoTmp(3) & 0x0002) ! 0 {
if CustomBtnInfo(16, CustomBtnid) ! 0 {
_FillRgn hdcButton, CustomBtnInfo(17, CustomBtnid), _GetSysColorBrush(syscrFrame(0))
_FillRgn hdcButton, CustomBtnInfo(18, CustomBtnid), _GetSysColorBrush(syscrFrame(2))
} else {
_DrawEdge hdcButton, varptr(DIS.DIS_rcItem0), stateDE, 0x100F
}
}
if (CustomBtnInfo(11, CustomBtnid) & 0x1000) ! 0 { mref BMSCR, 96+CustomBtnInfo(10, CustomBtnid)
_GetWindowRect DIS.DIS_hwndItem, varptr(rectTmp)
_ScreenToClient BMSCR(13), varptr(rectTmp(0))
_GetWindowLong BMSCR(13), -16
oldStyle=stat
_SetWindowLong BMSCR(13), -16, oldStyle & 0xFDFFFFFF
hdcParent=_GetDC(BMSCR(13))
if (CustomBtnInfo(11, CustomBtnid) & 0x0800) ! 0 { _Bitblt BMSCR(4), rectTmp(0), rectTmp(1), DIS.DIS_rcItem2, DIS.DIS_rcItem3, hdcButton, 0, 0, 0x00CC0020
}
_Bitblt hdcParent, rectTmp(0), rectTmp(1), DIS.DIS_rcItem2, DIS.DIS_rcItem3, hdcButton, 0, 0, 0x00CC0020
_ReleaseDC BMSCR(13), hdcParent
_SetWindowLong BMSCR(13), -16, oldStyle
} else : if (CustomBtnInfo(11, CustomBtnid) & 0x2000) ! 0 { if CustomBtnInfo(16, CustomBtnid) ! 0 : _SelectObject DIS.DIS_hDC, CustomBtnInfo(16, CustomBtnid)
_Bitblt DIS.DIS_hDC, 0, 0, DIS.DIS_rcItem2, DIS.DIS_rcItem3, hdcButton, 0, 0, 0x00CC0020
}
_DeleteDC hdcButton
_DeleteObject hbmButton
rp=1
break
}
loop
}
return rp
#define global removecustom(%1=-1) _removecustomsetting@_OD_BUTTON_ %1
#deffunc _removecustomsetting@_OD_BUTTON_ int _p1
rp=0
if initcustomizebutton ! 0 {
repeat CustomBtnidlimit
i=0
if _p1=-2 {
i=10
} else : if _p1=-1 {
if ginfo(3)=CustomBtnInfo(10, cnt) : i=10
} else {
if objInfo(_p1, 2)=CustomBtnInfo(0, cnt) : i=1
}
if i>0 {
if CustomBtnInfo(0, cnt) ! 0 {
if CustomBtnInfo(13, cnt) ! 0 : _DeleteObject CustomBtnInfo(13, cnt)
if CustomBtnInfo(15, cnt) ! 0 {
_SetWindowRgn CustomBtnInfo(0, cnt), 0, 0
if CustomBtnInfo(16, cnt) ! 0 : _DeleteObject CustomBtnInfo(16, cnt)
if CustomBtnInfo(17, cnt) ! 0 : _DeleteObject CustomBtnInfo(17, cnt)
if CustomBtnInfo(18, cnt) ! 0 : _DeleteObject CustomBtnInfo(18, cnt)
if CustomBtnInfo(19, cnt) ! 0 : _DeleteObject CustomBtnInfo(19, cnt)
}
_GetWindowLong CustomBtnInfo( 0, cnt), -12
_SetWindowLong CustomBtnInfo(14, cnt), -12, stat
oldgsel=ginfo(3)
gsel CustomBtnInfo(10, cnt), 0
_GetWindowRect CustomBtnInfo( 0, cnt), varptr(rectTmp)
_ScreenToClient hwnd, varptr(rectTmp(0))
_ScreenToClient hwnd, varptr(rectTmp(2))
_MoveWindow CustomBtnInfo(14, cnt), rectTmp(0), rectTmp(1), rectTmp(2)-rectTmp(0), rectTmp(3)-rectTmp(1), 0
textBtn=""
_GetWindowTextLength CustomBtnInfo( 0, cnt)
if stat ! 0 : _GetWindowText CustomBtnInfo( 0, cnt), varptr(textBtn), limit(stat+1, 0, 255)
_SetWindowText CustomBtnInfo(14, cnt), varptr(textBtn)
setobjinfo CustomBtnInfo(1, cnt), 2, CustomBtnInfo(14, cnt)
gsel oldgsel, 0
_DestroyWindow CustomBtnInfo(0, cnt)
_ShowWindow CustomBtnInfo(14, cnt), 8
j=cnt
repeat 20
CustomBtnInfo(cnt, j)=0
loop
rp=1
if i=1 : break
}
}
loop
}
return rp
#define global cbtnredraw(%1=-1) _custombuttonredraw@_OD_BUTTON_ %1
#deffunc _custombuttonredraw@_OD_BUTTON_ int _p1
rp=0
if initcustomizebutton ! 0 {
repeat CustomBtnidlimit
i=0
if _p1=-2 {
i=10
} else : if _p1=-1 {
if ginfo(3)=CustomBtnInfo(10, cnt) : i=10
} else {
if objInfo(_p1, 2)=CustomBtnInfo(0, cnt) : i=1
}
if i>0 {
if CustomBtnInfo(0, cnt) ! 0 {
_InvalidateRect CustomBtnInfo(0, cnt), 0, 0
rp=1
if i=1 : break
}
}
loop
}
return rp
#deffunc destroycustombutton onexit
if initcustomizebutton ! 0 {
removecustom -2
_DeleteObject hbmFrame
initcustomizebutton=0
}
return
#deffunc objredraw int _p1
if objInfo(_p1, 2) ! 0 : _InvalidateRect objInfo(_p1, 2), 0, 0
return
#global
#endif
#endif
|