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
|
-
|
|
|
|
!
-
|
|
!
-
-
|
!
!
-
|
|
|
|
|
|
-
|
-
|
-
|
|
|
|
!
|
|
|
-
|
-
-
|
|
|
!
|
!
|
!
-
|
-
|
|
|
|
|
|
|
!
|
|
!
|
!
-
-
|
|
|
|
!
!
-
|
|
|
-
|
-
|
|
!
-
|
|
!
|
|
!
-
-
|
|
!
!
-
|
|
!
-
|
|
|
|
-
|
|
|
!
-
|
|
!
-
|
-
|
!
-
|
|
|
!
-
|
|
|
-
|
|
|
!
!
| #module mod_imgbtn
#uselib "gdi32"
#func GetTextExtentPoint32A "GetTextExtentPoint32A" int,str,int,sptr
#uselib "user32"
#func SetCapture "SetCapture" int
#func ReleaseCapture "ReleaseCapture"
#enum global IB_NOMAL
#enum global IB_SELECT
#enum global IB_CLICK
#enum WINID = 0
#enum PX
#enum PY
#enum WX
#enum WY
#deffunc imgbtn_setbtn int _btndataid, int _type, int _winid, int _x, int _y, int _w, int _h
if length(data)<=1:dim data,64,4,5 data(_btndataid,_type,WINID)=_winid
data(_btndataid,_type,PX)=_x
data(_btndataid,_type,PY)=_y
data(_btndataid,_type,WX)=_w
data(_btndataid,_type,WY)=_h
return
#deffunc imgbtn str _title, str _flagID, int _btnid
if length(btn_int)=1:dim btn_int, 64, 256, 3
if length(btn_str)=1:sdim btn_str,32, 64, 256, 2
if length(btnmax)=1:dim btnmax,64
if count=256:dialog "これ以上オブジェクトを登録できません":end
btn_int(ginfo_sel,count,0)=ginfo_cx
btn_int(ginfo_sel,count,1)=ginfo_cy
btn_int(ginfo_sel,count,2)=_btnid
btn_str(ginfo_sel,count,0)=_title
btn_str(ginfo_sel,count,1)=_flagID
btnmax(ginfo_sel)=count+1
dim textsize,2
GetTextExtentPoint32A hdc, btn_str(ginfo_sel,count,0), strlen(btn_str(ginfo_sel,count,0)),varptr(textsize)
tx(count)=btn_int(ginfo_sel,count,0)+(data(btn_int(ginfo_sel,count,2),IB_NOMAL,WX)-textsize(0)>>1)
ty(count)=btn_int(ginfo_sel,count,1)+(data(btn_int(ginfo_sel,count,2),IB_NOMAL,WY)-textsize(1)>>1)
count+
return
#deffunc imgbtn_input var _var
notesel _var
dim btn_int,256,notemax,2
sdim btn_str,64,256,notemax,2
repeat notemax
noteget s5,cnt
s1=0
repeat
getstr s2,s5,s1,' ' : s1+=strsize
if s2=""{continue}else{break}
loop
repeat
getstr s3,s5,s1,' ' : s1+=strsize
if s3=""{continue}else{break}
loop
repeat
getstr s4,s5,s1,' ' : s1+=strsize
if s4="\"\"":s4="":break
if s4=""{continue}else{break}
loop
repeat
getstr s6,s5,s1,' ' : s1+=strsize
if s6=""{continue}else{break}
loop
repeat 5
getstr s7,s5,s1,' ' : s1+=strsize
if s7=""{continue}else{break}
loop
btn_int(ginfo_sel,cnt,0)=int(s2)
btn_int(ginfo_sel,cnt,1)=int(s3) btn_int(ginfo_sel,cnt,2)=int(s7)
btn_str(ginfo_sel,cnt,0)=s4 btn_str(ginfo_sel,cnt,1)=s6
dim textsize,2
GetTextExtentPoint32A hdc, btn_str(ginfo_sel,cnt,0), strlen(btn_str(ginfo_sel,cnt,0)),varptr(textsize)
tx(cnt)=btn_int(ginfo_sel,cnt,0)+(data(btn_int(ginfo_sel,cnt,2),IB_NOMAL,WX)-textsize(0)>>1)
ty(cnt)=btn_int(ginfo_sel,cnt,1)+(data(btn_int(ginfo_sel,cnt,2),IB_NOMAL,WY)-textsize(1)>>1)
loop
btnmax(ginfo_sel)=notemax
dim movelock,5,btnmax(ginfo_sel)
dim im_red,btnmax(ginfo_sel)
return
#defcfunc imgbtn_check int _iparam, int _lparam
if imgbtn_start=0{
dim movelock,5,btnmax(ginfo_sel)
dim im_red,btnmax(ginfo_sel)
imgbtn_start=1
return 1
}
if (_iparam=512)|(_iparam=513)|(_iparam=514){
mx=(_lparam & 0xFFFF)
my=((_lparam >> 16 ) & 0xFFFF)
}
imgbtn_redraw=0
dim im_red,btnmax(ginfo_sel)
repeat btnmax(ginfo_sel)
if (_iparam=513)|(_iparam=514){
if (btn_int(ginfo_sel,cnt,0)<mx) & (btn_int(ginfo_sel,cnt,1)<my) & (btn_int(ginfo_sel,cnt,0)+data(btn_int(ginfo_sel,cnt,2),IB_NOMAL,WX)>mx) & (btn_int(ginfo_sel,cnt,1)+data(btn_int(ginfo_sel,cnt,2),IB_NOMAL,WY)>my){
imgbtn_redraw=1
}
}
if _iparam=512{
if (btn_int(ginfo_sel,cnt,0)<mx) & (btn_int(ginfo_sel,cnt,1)<my) & (btn_int(ginfo_sel,cnt,0)+data(btn_int(ginfo_sel,cnt,2),IB_NOMAL,WX)>mx) & (btn_int(ginfo_sel,cnt,1)+data(btn_int(ginfo_sel,cnt,2),IB_NOMAL,WY)>my){
movelock(0,cnt)=0 if selected=0{
if movelock(1,cnt)=0{
imgbtn_redraw=1 im_red(cnt)=IB_SELECT movelock(1,cnt)=1
}
}else{
if imgbtnsel=cnt{
if movelock(2,cnt)=0{
imgbtn_redraw=1 im_red(cnt)=IB_CLICK movelock(2,cnt)=1
}
}
}
}else{
if movelock(0,cnt)=0{
imgbtn_redraw=1 im_red(cnt)=IB_NOMAL
movelock(0,cnt)=1
}
if movelock(2,cnt)=1:movelock(2,cnt)=0
if movelock(1,cnt)=1:movelock(1,cnt)=0
}
}
if _iparam=513{
if (selected=0) & (btn_int(ginfo_sel,cnt,0)<mx) & (btn_int(ginfo_sel,cnt,1)<my) & (btn_int(ginfo_sel,cnt,0)+data(btn_int(ginfo_sel,cnt,2),IB_NOMAL,WX)>mx) & (btn_int(ginfo_sel,cnt,1)+data(btn_int(ginfo_sel,cnt,2),IB_NOMAL,WY)>my){
im_red(cnt)=IB_CLICK
selected=1
SetCapture hwnd
imgbtnsel=cnt
}
}
if _iparam=514{
if (btn_int(ginfo_sel,cnt,0)<mx) & (btn_int(ginfo_sel,cnt,1)<my) & (btn_int(ginfo_sel,cnt,0)+data(btn_int(ginfo_sel,cnt,2),IB_NOMAL,WX)>mx) & (btn_int(ginfo_sel,cnt,1)+data(btn_int(ginfo_sel,cnt,2),IB_NOMAL,WY)>my){
im_red(cnt)=IB_SELECT
if (selected=1)&(imgbtnsel=cnt){
hit=1
hitid=cnt
}
}else{
im_red(cnt)=IB_NOMAL
}
}
loop
if selected=1{
if _iparam=512{
getkey key,1
if key=0:selected=0
}
}
if _iparam=514{
selected=0
ReleaseCapture
}
return imgbtn_redraw
#deffunc imgbtn_draw
redraw 0
repeat btnmax(ginfo_sel)
switch im_red(cnt)
case IB_NOMAL
pos btn_int(ginfo_sel,cnt,0), btn_int(ginfo_sel,cnt,1)
gcopy data(btn_int(ginfo_sel,cnt,2),IB_NOMAL,WINID), data(btn_int(ginfo_sel,cnt,2),IB_NOMAL,PX), data(btn_int(ginfo_sel,cnt,2),IB_NOMAL,PY), data(btn_int(ginfo_sel,cnt,2),IB_NOMAL,WX), data(btn_int(ginfo_sel,cnt,2),IB_NOMAL,WY)
pos tx(cnt),ty(cnt):mes btn_str(ginfo_sel,cnt,0)
swbreak
case IB_CLICK
pos btn_int(ginfo_sel,cnt,0), btn_int(ginfo_sel,cnt,1)
gcopy data(btn_int(ginfo_sel,cnt,2),IB_CLICK,WINID), data(btn_int(ginfo_sel,cnt,2),IB_CLICK,PX), data(btn_int(ginfo_sel,cnt,2),IB_CLICK,PY), data(btn_int(ginfo_sel,cnt,2),IB_CLICK,WX), data(btn_int(ginfo_sel,cnt,2),IB_CLICK,WY)
pos tx(cnt)+1,ty(cnt)+1:mes btn_str(ginfo_sel,cnt,0)
swbreak
case IB_SELECT
pos btn_int(ginfo_sel,cnt,0), btn_int(ginfo_sel,cnt,1)
gcopy data(btn_int(ginfo_sel,cnt,2),IB_SELECT,WINID), data(btn_int(ginfo_sel,cnt,2),IB_SELECT,PX), data(btn_int(ginfo_sel,cnt,2),IB_SELECT,PY), data(btn_int(ginfo_sel,cnt,2),IB_SELECT,WX), data(btn_int(ginfo_sel,cnt,2),IB_SELECT,WY)
pos tx(cnt),ty(cnt):mes btn_str(ginfo_sel,cnt,0)
swbreak
swend
loop
if hit=1{
hit=0
hitidstr=btn_str(ginfo_sel,hitid,1)
redraw 1
return 1
}else{
hitidstr=""
redraw 1
return 0
}
#defcfunc ibjump
return hitidstr
btn_int(ginfo_sel,cnt,0)=int(s2)
btn_int(ginfo_sel,cnt,1)=int(s3)
btn_str(ginfo_sel,cnt,0)=s4 btn_str(ginfo_sel,cnt,1)=s6
#defcfunc ibid str _str
repeat btnmax(ginfo_sel)
s1=0
if btn_str(ginfo_sel,cnt,1)=_str{
s1=cnt
break
}
loop
if s1=0:return -1
return s1
#deffunc ibpos int _id, int _x, int _y
btn_int(ginfo_sel,_id,0)=_x
btn_int(ginfo_sel,_id,1)=_y
GetTextExtentPoint32A hdc, btn_str(ginfo_sel,_id,0), strlen(btn_str(ginfo_sel,_id,0)),varptr(textsize)
tx(_id)=btn_int(ginfo_sel,_id,0)+(data(btn_int(ginfo_sel,_id,2),IB_NOMAL,WX)-textsize(0)>>1)
ty(_id)=btn_int(ginfo_sel,_id,1)+(data(btn_int(ginfo_sel,_id,2),IB_NOMAL,WY)-textsize(1)>>1)
return
#deffunc ibtitle int _id, str _str
btn_str(ginfo_sel,_id,0)=_str dim textsize,2
GetTextExtentPoint32A hdc, _str, strlen(_str),varptr(textsize)
tx(_id)=btn_int(ginfo_sel,_id,0)+(data(btn_int(ginfo_sel,_id,2),IB_NOMAL,WX)-textsize(0)>>1)
ty(_id)=btn_int(ginfo_sel,_id,1)+(data(btn_int(ginfo_sel,_id,2),IB_NOMAL,WY)-textsize(1)>>1)
return
#deffunc imgbtn_titleoption int _flag
if _flag=1{
downsize=1
}else{
downsize=0
}
return
#global
#if 1
buffer 2
color
boxf 0,0,99,20
color 210,210,210
boxf 0,0,98,19
color
boxf 0,21,99,41
color 180,180,180
boxf 0,21,98,40
color
boxf 0,42,99,62
color 180,180,180
boxf 1,43,99,62
screen 0
sysfont 17
imgbtn_setbtn 0,IB_NOMAL, 2, 0, 0, 100, 21 imgbtn_setbtn 0,IB_SELECT, 2, 0, 21, 100, 21 imgbtn_setbtn 0,IB_CLICK, 2, 0, 42, 100, 21
imgbtn_setbtn 1,IB_SELECT, 2, 0, 0, 100, 21 imgbtn_setbtn 1,IB_CLICK, 2, 0, 21, 100, 21 imgbtn_setbtn 1,IB_NOMAL, 2, 0, 42, 100, 21
s1={"
20 20 HSP hsp
100 100 ボタン test
23 300 Click click 1
"}
imgbtn_input s1
#define WM_MOUSEMOVE $00000200
#define WM_LBUTTONDOWN $00000201
#define WM_LBUTTONUP $00000202
oncmd gosub *ON_WM_MOUSEMOVE,WM_MOUSEMOVE
oncmd gosub *ON_WM_LBUTTONDOWN,WM_LBUTTONDOWN
oncmd gosub *ON_WM_LBUTTONUP,WM_LBUTTONUP
gosub *draw
gsel 0,1
stop
*ON_WM_MOUSEMOVE
gosub *draw
return
*ON_WM_LBUTTONDOWN
gosub *draw
return
*ON_WM_LBUTTONUP
gosub *draw
return
*draw
redraw 0
gsel 0
if imgbtn_check(iparam,lparam)=1{
color 223,234,111 : boxf : color imgbtn_draw if stat=1{
if ibjump()="hsp":ibtitle 0,""+cc:cc+:imgbtn_draw if ibjump()="test":ibpos 1,233,23 if ibjump()="click":dialog "ボタンデータのIDを変更するとボタンイメージを変えることができます。"
}
}
redraw 1
return
#endif
|