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
|
-
|
|
|
-
|
|
!
|
#uselib "user32.dll"
#cfunc GetWindowLong "GetWindowLongA" int,int
#func SetWindowLong "SetWindowLongA" int,int,int
#func SetWindowRgn "SetWindowRgn" int,int,int
#func SetParent "SetParent" int,int
#func GetWindowRect "GetWindowRect" int,sptr
#func ScreenToClient "ScreenToClient" int,sptr
#uselib "gdi32.dll"
#cfunc CreateEllipticRgn "CreateEllipticRgn" int,int,int,int
#func Arc "Arc" int,int,int,int,int,int,int,int,int
#define BS_OWNERDRAW 0x0000000B
#define WS_CLIPCHILDREN 0x02000000
#define WM_DRAWITEM 0x002B
#define GWL_STYLE (-16)
#define GWL_HWNDPARENT (-8)
#define ODS_SELECTED 0x0001
#define BTNW 51 #define BTNH 51
style = GetWindowLong(hwnd, GWL_STYLE)
style = style & (WS_CLIPCHILDREN) ^ style
SetWindowLong hwnd, GWL_STYLE, style
objsize BTNW, BTNH
pos 100, 100
button gosub "", *ButtonClick
style = GetWindowLong(objinfo(0,2), GWL_STYLE)
style = style | BS_OWNERDRAW
SetWindowLong objinfo(0,2), GWL_STYLE, style
SetParent objinfo(0,2), 0 hrgn = CreateEllipticRgn(0, 0, BTNW, BTNH)
SetWindowRgn objinfo(0,2), hrgn, 1
SetParent objinfo(0,2),hwnd
oncmd gosub *On_DrawItem, WM_DRAWITEM
#ifdef FLAT
buffer 2, BTNW+1, BTNH+1
syscolor 15
boxf
syscolor 20
circle 0, 0, BTNW+1, BTNH+1
syscolor 15
circle 1, 1, BTNW, BTNH
buffer 3, BTNW+1, BTNH+1
syscolor 15
boxf
syscolor 21
circle 0, 0, BTNW+1, BTNH+1
syscolor 16
circle 1, 1, BTNW, BTNH
#else
buffer 2, BTNW+1, BTNH+1
syscolor 15
boxf
syscolor 21 circle 1,1,BTNW+1,BTNH+1
syscolor 20 circle 0,0,BTNW-1,BTNH-1
syscolor 16 circle 1,1,BTNW,BTNH
syscolor 15 circle 1,1,BTNW-1,BTNH-1
buffer 3, BTNW+1, BTNH+1
syscolor 15
boxf
syscolor 21 circle 0,0,BTNW,BTNH
syscolor 16 circle 1,1,BTNW+1,BTNH+1
syscolor 20 circle 2,2,BTNW+1,BTNH+1
syscolor 15 circle 2,2,BTNW,BTNH
#endif
gsel 0
syscolor 15
boxf
stop
*On_DrawItem
dupptr dis, lparam, 48
dim rc, 4
GetWindowRect dis.5, varptr(rc)
ScreenToClient hwnd, varptr(rc.0)
if (dis.4 & ODS_SELECTED){
pos rc.0, rc.1
gcopy 3, 0, 0, BTNW+1, BTNH+1
}else{
pos rc.0, rc.1
gcopy 2, 0, 0, BTNW+1, BTNH+1
}
return 1
*ButtonClick
title "Clicked("+ClkCount+")"
ClkCount++
return
|