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
|
-
|
|
|
|
|
|
|
!
-
-
|
|
|
|
-
|
|
|
|
|
|
|
!
|
|
!
-
|
|
|
-
|
|
|
|
|
|
|
!
|
|
|
|
-
-
-
|
|
|
|
-
|
|
|
|
|
|
|
!
|
!
-
-
|
|
|
-
|
|
|
|
|
|
|
|
!
|
|
|
!
|
!
|
!
-
|
|
|
-
|
|
|
|
|
|
|
!
|
|
|
!
-
|
|
|
-
|
|
|
|
|
|
|
!
|
-
|
!
-
|
|
-
|
!
-
|
-
|
!
-
|
|
-
|
!
-
|
-
|
!
-
-
|
-
|
!
-
|
!
-
|
-
|
!
-
|
|
|
-
|
|
|
|
!
|
|
|
-
|
|
|
|
!
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
!
|
#module module_imgbtn m_btntext, m_width, m_height, m_btn_default_hspwinid, m_btn_default_width, m_btn_default_height, m_btn_mouse_hspwinid, m_btn_mouse_width, m_btn_mouse_height, m_btn_push_hspwinid, m_btn_push_width, m_btn_push_height, m_cx, m_cy, m_hspwinid, m_hsphwnd, m_drawstat, m_drawstat2, m_id, m_btntext_px, m_btntext_py, m_r, m_g, m_b, m_gmode
#define WM_LBUTTONUP $00000202
#define WM_LBUTTONDOWN $00000201
#define WM_MOUSEMOVE $00000200
#uselib "user32.dll"
#func SetCapture "SetCapture" sptr
#func ReleaseCapture "ReleaseCapture"
#uselib "gdi32"
#func GetTextExtentPoint32A "GetTextExtentPoint32A" sptr,sptr,sptr,sptr
#modfunc mod_imgbtn_draw int _message, int _lparam, int _ginfo_intid, local s1, local s2, local s3, local s4, local s5, local s6
s1 = _lparam & 0xFFFF s2 = (_lparam >> 16) & 0xFFFF s3 = ginfo_sel gsel m_hspwinid
switch _message
case 0
gmode m_gmode
pos m_cx, m_cy
gcopy m_btn_default_hspwinid, m_btn_default_width, m_btn_default_height, m_width, m_height if m_btntext != ""{
s4 = ginfo_r
s5 = ginfo_g
s6 = ginfo_b
pos m_btntext_px, m_btntext_py
color m_r, m_g, m_b
mes m_btntext
color s4, s5, s6
}
pos m_cx, m_cy+m_height
swbreak
case WM_MOUSEMOVE
if m_hspwinid != _ginfo_intid : swbreak
if (drawid != m_id)&(drawflag == 1) :swbreak if (m_drawstat!=2)&(s1>=m_cx)&(s1<m_cx+m_width)&(s2>=m_cy)&(s2<m_cy+m_height){
if m_drawstat=0{
gmode m_gmode
pos m_cx, m_cy
gcopy m_btn_mouse_hspwinid, m_btn_mouse_width, m_btn_mouse_height, m_width, m_height
if m_btntext != ""{
s4 = ginfo_r
s5 = ginfo_g
s6 = ginfo_b
pos m_btntext_px, m_btntext_py
color m_r, m_g, m_b
mes m_btntext
color s4, s5, s6
}
m_drawstat = 1 SetCapture m_hsphwnd
}
}else:if m_drawstat = 1{
gmode m_gmode
pos m_cx, m_cy
gcopy m_btn_default_hspwinid, m_btn_default_width, m_btn_default_height, m_width, m_height if m_btntext != ""{
s4 = ginfo_r
s5 = ginfo_g
s6 = ginfo_b
pos m_btntext_px, m_btntext_py
color m_r, m_g, m_b
mes m_btntext
color s4, s5, s6
}
m_drawstat = 0 ReleaseCapture
}else:if m_drawstat = 2{
if (s1>=m_cx)&(s1<=m_cx+m_width)&(s2>=m_cy)&(s2<=m_cy+m_height){
if m_drawstat2 = 0{
gmode m_gmode
pos m_cx, m_cy
gcopy m_btn_push_hspwinid, m_btn_push_width, m_btn_push_height, m_width, m_height
if m_btntext != ""{
s4 = ginfo_r
s5 = ginfo_g
s6 = ginfo_b
pos m_btntext_px+1, m_btntext_py+1
color m_r, m_g, m_b
mes m_btntext
color s4, s5, s6
}
m_drawstat2 = 1 }
}else{
if m_drawstat2 == 1{
gmode m_gmode
pos m_cx, m_cy
gcopy m_btn_default_hspwinid, m_btn_default_width, m_btn_default_height, m_width, m_height if m_btntext != ""{
s4 = ginfo_r
s5 = ginfo_g
s6 = ginfo_b
pos m_btntext_px, m_btntext_py
color m_r, m_g, m_b
mes m_btntext
color s4, s5, s6
}
m_drawstat2 = 0
}
}
}
swbreak
case WM_LBUTTONDOWN
if m_hspwinid != _ginfo_intid : swbreak
if (m_drawstat==1)&(s1>=m_cx)&(s1<=m_cx+m_width)&(s2>=m_cy)&(s2<=m_cy+m_height){
gmode m_gmode
pos m_cx, m_cy
gcopy m_btn_push_hspwinid, m_btn_push_width, m_btn_push_height, m_width, m_height if m_btntext != ""{
s4 = ginfo_r
s5 = ginfo_g
s6 = ginfo_b
pos m_btntext_px+1, m_btntext_py+1
color m_r, m_g, m_b
mes m_btntext
color s4, s5, s6
}
m_drawstat = 2 drawflag = 1
drawid = m_id
}
swbreak
case WM_LBUTTONUP
if m_hspwinid != _ginfo_intid : swbreak
if (m_drawstat==2)&(s1>=m_cx)&(s1<=m_cx+m_width)&(s2>=m_cy)&(s2<=m_cy+m_height){
gmode m_gmode
pos m_cx, m_cy
gcopy m_btn_mouse_hspwinid, m_btn_mouse_width, m_btn_mouse_height, m_width, m_height if m_btntext != ""{
s4 = ginfo_r
s5 = ginfo_g
s6 = ginfo_b
pos m_btntext_px, m_btntext_py
color m_r, m_g, m_b
mes m_btntext
color s4, s5, s6
}
m_drawstat = 1 }else{
m_drawstat = 0
}
drawflag = 0
ReleaseCapture
swbreak
swend
gsel s3
return
#deffunc imgbtn_draw int _message, int _lparam, int _ginfo_intid
foreach ib
mod_imgbtn_draw ib(cnt), _message, _lparam, _ginfo_intid
loop
return
#modfunc mod_imgbtn_check_id var _id, int _lparam, int _ginfo_intid, local s1, local s2
if m_hspwinid != _ginfo_intid : return 0
s1 = _lparam & 0xFFFF s2 = (_lparam >> 16) & 0xFFFF if (s1>=m_cx)&(s1<=m_cx+m_width)&(s2>=m_cy)&(s2<=m_cy+m_height){
_id = m_id
return 1
}else{
return 0
}
#defcfunc imgbtn_check_id int _lparam, int _ginfo_intid, local s1, local s2
foreach ib
mod_imgbtn_check_id ib(cnt), s1, _lparam, _ginfo_intid
if stat == 1 : s2 = 1 : break
loop
if s2 == 1 {
return s1
}else{
return -1
}
#modfunc mod_imgbtn_check_text var _text, int _lparam, int _ginfo_intid, local s1, local s2
if m_hspwinid != _ginfo_intid : return 0
s1 = _lparam & 0xFFFF s2 = (_lparam >> 16) & 0xFFFF if (s1>=m_cx)&(s1<=m_cx+m_width)&(s2>=m_cy)&(s2<=m_cy+m_height){
_text = m_btntext
return 1
}else{
return 0
}
#defcfunc imgbtn_check_text int _lparam, int _ginfo_intid, local s1, local s2
foreach ib
mod_imgbtn_check_text ib(cnt), s1, _lparam, _ginfo_intid
if stat == 1 : s2 = 1 : break
loop
if s2 == 1 {
return s1
}else{
return -1
}
#modfunc mod_imgbtn_settext str _text, local s1
m_btntext = _text
dim s1, 2
GetTextExtentPoint32A hdc, m_btntext, strlen(m_btntext) , varptr(s1)
m_btntext_px = m_cx + (m_width - s1.0)/2
m_btntext_py = m_cy + (m_height - s1.1)/2
mod_imgbtn_draw thismod
return
#deffunc imgbtn_settext int _id, str _text
mod_imgbtn_settext ib(_id), _text
return
#modfunc mod_imgbtn_gettext
return m_btntext
#defcfunc imgbtn_gettext int _id
mod_imgbtn_gettext ib(_id)
return stat
#modfunc mod_imgbtn_alldraw int _hspwinid
if m_hspwinid != m_hspwinid : return
mod_imgbtn_draw thismod
return
#deffunc imgbtn_alldraw int _hspwinid
foreach ib
mod_imgbtn_alldraw ib(cnt), _hspwinid
loop
return
#defcfunc imgbtn_bgcc int _lparam, int _ginfo_intid
if btnflag {
if btnid == imgbtn_check_id(_lparam, _ginfo_intid){
return 1
}else{
return 0
}
}else{
return 0
}
#deffunc imgbtn_bgc int _lparam, int _ginfo_intid btnid = imgbtn_check_id(_lparam, _ginfo_intid)
if btnid == -1{
btnflag = 0
}else{
btnflag = 1
}
return
#modfunc mod_imgbtn_select int _padding, local s1, local s2, local s3, local s4
s1 = m_cx+2+_padding
s2 = m_cy+2+_padding
s3 = m_width-5-_padding*2
s4 = m_height-5-_padding*2
color
repeat s3/2+1
pset s1+cnt*2,s2
loop
repeat s3/2+1
pset s1+cnt*2,s2+s4
loop
repeat s4/2
pset s1,s2+cnt*2
loop
repeat s4/2-1
pset s1+s3,s2+cnt*2+2
loop
return
#deffunc imgbtn_select int _id, int _padding
mod_imgbtn_select ib(_id), _padding
return
#modinit str _btntext, int _width, int _height, int _btn_default_hspwinid, int _btn_default_width, int _btn_default_height, int _btn_mouse_hspwinid, int _btn_mouse_width, int _btn_mouse_height, int _btn_push_hspwinid, int _btn_push_width, int _btn_push_height, int _gmode, local s1
m_btntext = _btntext
m_width = _width
m_height = _height
m_btn_default_hspwinid = _btn_default_hspwinid
m_btn_default_width = _btn_default_width
m_btn_default_height = _btn_default_height
m_btn_mouse_hspwinid = _btn_mouse_hspwinid
m_btn_mouse_width = _btn_mouse_width
m_btn_mouse_height = _btn_mouse_height
m_btn_push_hspwinid = _btn_push_hspwinid
m_btn_push_width = _btn_push_width
m_btn_push_height = _btn_push_height
m_hspwinid = ginfo_sel
m_cx = ginfo_cx
m_cy = ginfo_cy
m_id = idcount
m_hsphwnd = hwnd
m_gmode = _gmode
dim s1, 2
GetTextExtentPoint32A hdc, m_btntext, strlen(m_btntext) , varptr(s1)
m_btntext_px = m_cx + (m_width - s1.0)/2
m_btntext_py = m_cy + (m_height - s1.1)/2
m_r = ginfo_r
m_g = ginfo_g
m_b = ginfo_b
idcount++
return m_id
#deffunc imgbtn str _btntext, int _width, int _height, int _btn_default_hspwinid, int _btn_default_width, int _btn_default_height, int _btn_mouse_hspwinid, int _btn_mouse_width, int _btn_mouse_height, int _btn_push_hspwinid, int _btn_push_width, int _btn_push_height, local s1
newmod ib, module_imgbtn, _btntext, _width, _height, _btn_default_hspwinid, _btn_default_width, _btn_default_height, _btn_mouse_hspwinid, _btn_mouse_width, _btn_mouse_height, _btn_push_hspwinid, _btn_push_width, _btn_push_height
s1 = stat
mod_imgbtn_draw ib(s1)
return s1
#global
#if 1
#define WM_LBUTTONUP $00000202
#define WM_LBUTTONDOWN $00000201
#define WM_MOUSEMOVE $00000200
buffer 1
color
boxf 1,1,99,20
color 210,210,210
boxf 1,1,98,19
color
boxf 1,22,99,41
color 180,180,180
boxf 1,22,98,40
color
boxf 0,42,98,61
color 180,180,180
boxf 1,43,98,61
screen 0, 200,200, , 10,10
oncmd gosub *ON_WM_LBUTTONDOWN, WM_LBUTTONDOWN
oncmd gosub *ON_WM_LBUTTONUP, WM_LBUTTONUP
oncmd gosub *ON_WM_MOUSEMOVE, WM_MOUSEMOVE
color 240,240,240
boxf
pos 45,140
color 255
font msgothic, 12
imgbtn "★", 100, 21, 1, 0, 0, 1, 0, 21, 1, 0, 42
pos ginfo_cx, ginfo_cy+5
color 0,0,255
imgbtn "", 100, 21, 1, 0, 0, 1, 0, 21, 1, 0, 42
screen 2, 120,120, , 400,10
oncmd gosub *ON_WM_LBUTTONDOWN, WM_LBUTTONDOWN
oncmd gosub *ON_WM_LBUTTONUP, WM_LBUTTONUP
oncmd gosub *ON_WM_MOUSEMOVE, WM_MOUSEMOVE
pos 10,10
color 240,240,240
boxf
sysfont 17
color
imgbtn "メモ帳を起動", 100, 21, 1, 0, 0, 1, 0, 21, 1, 0, 42
imgbtn "ペイントを起動", 100, 21, 1, 0, 0, 1, 0, 21, 1, 0, 42
imgbtn "TEST", 100, 21, 1, 0, 0, 1, 0, 21, 1, 0, 42
imgbtn "TEST", 100, 21, 1, 0, 0, 1, 0, 21, 1, 0, 42
gsel 0
stop
*ON_WM_MOUSEMOVE
gmode 7
font msgothic, 12
imgbtn_draw WM_MOUSEMOVE, lparam, ginfo_intid
return
*ON_WM_LBUTTONUP
redraw 0
font msgothic, 12
imgbtn_draw WM_LBUTTONUP, lparam, ginfo_intid
if imgbtn_bgcc(lparam, ginfo_intid){
switch imgbtn_check_id(lparam, ginfo_intid)
case 0
if flag == 0{
flag = 1
imgbtn_settext 0, ""
imgbtn_settext 1, "★"
count++
}
swbreak
case 1
if flag == 1{
flag = 0
imgbtn_settext 1, ""
imgbtn_settext 0, "★"
count++
}
swbreak
swend
switch imgbtn_check_text(lparam, ginfo_intid)
case "メモ帳を起動"
exec "notepad.exe"
swbreak
case "ペイントを起動"
exec "mspaint.exe"
swbreak
swend
color 240,240,240
boxf 00, 20, ginfo_winx,ginfo_winy-80
color
font msgothic, 100
pos 90, 24 : mes count
}
redraw 1
return
*ON_WM_LBUTTONDOWN
gmode 7
font msgothic, 12
imgbtn_draw WM_LBUTTONDOWN, lparam, ginfo_intid
imgbtn_bgc lparam, ginfo_intid return
#endif
|