今のところこうやっているのですが。。。
#include "user32.as"
#module mod_ebutton
#deffunc ebutton_init int _maxnum
ldim btn_label, _maxnum
dim btn_ctr
dim btn_x, _maxnum
dim btn_y, _maxnum
dim btn_width, _maxnum
dim btn_height, _maxnum
dim btnimg_normal, _maxnum
dim btnimg_onmouse, _maxnum
dim btnimg_onclick, _maxnum
return
#define EBUTTON_TIMER_ID 1
#define EBUTTON_TIMER_ELAPSE 52
#define WM_TIMER 0x00000113
#define ctype between(%1, %2, %3) ((%1 >= %2) & (%1 <= %3))
#define true 1
#define false 0
#define STICK_LBUTTON 256
#define global ebutton(%1, %2, %3, %4) temp = %1 : _ebutton temp, %2, %3, %4
#deffunc _ebutton var lab, int _width, int _height, array btnbuf
btn_label(btn_ctr) = lab
btn_x(btn_ctr) = ginfo_cx
btn_y(btn_ctr) = ginfo_cy
btn_width(btn_ctr) = _width
btn_height(btn_ctr) = _height
btnimg_normal(btn_ctr) = btnbuf(0)
btnimg_onmouse(btn_ctr) = btnbuf(1)
btnimg_onclick(btn_ctr) = btnbuf(2)
btn_ctr++
SetTimer hwnd, EBUTTON_TIMER_ID, EBUTTON_TIMER_ELAPSE, 0
oncmd *CheckMousePos_Redraw, WM_TIMER
return
*CheckMousePos_Redraw
prev_cx = ginfo_cx
prev_cy = ginfo_cy
dim i
dim key
dim clicked
stick key, STICK_LBUTTON
repeat btn_ctr
pos btn_x(i), btn_y(i)
if (between(mousex, btn_x(i), btn_x(i) + btn_width(i) - 1)) & (between(mousey, btn_y(i), btn_y(i) + btn_height(i) - 1)) {
if (key & STICK_LBUTTON) {
gcopy btnimg_onclick(i), , , btn_width(i), btn_height(i)
wasclicked = true
break
} else {
if (wasclicked == true) : wasclicked = false : clicked = true
gcopy btnimg_onmouse(i), , , btn_width(i), btn_height(i)
break
}
} else {
gcopy btnimg_normal(i), , , btn_width(i), btn_height(i)
}
i++
loop
pos prev_cx, prev_cy
if (clicked == true) : goto btn_label(i)
stop
#global
ebutton_init
buffer 1
color 255 : boxf
buffer 2
color , 255 : boxf
buffer 3
color , , 255 : boxf
gsel 0, 1
buf = 1, 2, 3
pos 100, 100
ebutton *buttonclicked, 100, 50, buf
pos 0, 0
stop
*buttonclicked
color
mes "ボタンがクリックされました"
stop