Îã
¥¯¥ê¥Ã¥¯¤À¤Ã¤¿¤é¿§¤òÊѤ¨¤ë¤è¤¦¤Ë¤·¤Æ¤ß¤Þ¤·¤¿
// ¥É¥é¥Ã¥°¤Ç¤¤ë¶ë·Á
// ¥Þ¥¦¥¹¥«¡¼¥½¥ëÊѹ¹ÍÑÌ¿Îá¡Ê»²¹Í¡§http://lhsp.s206.xrea.com/hsp_mouse.html#3¡Ë
#uselib "user32"
#cfunc LoadCursor "LoadCursorA" nullptr, int
#func SetClassLong "SetClassLongA" int, int, int
// ¥¦¥£¥ó¥É¥¦¥á¥Ã¥»¡¼¥¸
#const WM_LBUTTONDOWN 0x0201
#const WM_LBUTTONUP 0x0202
//#const WM_MOUSEMOVE 0x0200 ¢«¡WM_MOUSEMOVE¤Ï°ì¡¹¥á¥Ã¥»¡¼¥¸½èÍý¤ò¤·¤Ê¤¤¤è¤¦¤Ë¤·¤Æ
#const Duration_Click 160 //¥¯¥ê¥Ã¥¯¤È¤ß¤Ê¤¹´Ö³Ö(ms)
// LoadCursorÍÑ°ú¿ô
#const IDC_ARROW 0x7F00
#const IDC_HAND 0x7F89
//
// ¶ë·Á¤ò°·¤¦¥â¥¸¥å¡¼¥ë
#module mdl_rect x, y, w, h, c
#const BORDER_WIDTH 2
#modinit int _x, int _y, int _w, int _h, int _c
x = _x : y = _y
w = _w : h = _h
c = _c \ 192
return
//
// ¶ë·Á¤Î¿§¤òÊѹ¹
#modfunc setcolor_rect int _c
c = _c \ 192
return
//
// ¶ë·Á¤òÉÁ²è
#modfunc draw_rect
hsvcolor c, 255, 191
boxf x, y, x + w, y + h
hsvcolor c, 255, 255
boxf x + BORDER_WIDTH, y + BORDER_WIDTH, x + w - BORDER_WIDTH, y + h - BORDER_WIDTH
return
//
// ¶ë·Á¤ò°ÜÆ°
#modfunc move_rect int _x, int _y
x = _x : y = _y
return
//
// ÅÀ¡Êpx, py¡Ë¤¬¶ë·ÁÆâ¤Ë¤¢¤ë¤«Èݤ«¤òÊÖ¤¹
#modfunc point_rect int px, int py
return ( x <= px ) & ( y <= py ) & ( px < x + w ) & ( py < y + h )
//
// ¶ë·Á¤ÎXºÂɸ¤òÊÖ¤¹
#modfunc get_x var ret
ret = x
return
//
// ¶ë·Á¤ÎYºÂɸ¤òÊÖ¤¹
#modfunc get_y var ret
ret = y
return
//
// º£¥Ý¥¤¥ó¥È¤·¤Æ¤¤¤ë¶ë·Á¤òÄ´¤Ù¡¢¤½¤ÎÇÛÎóÍ×ÁÇÈÖ¹æ¤òstat¤ËÊÖ¤¹¡Ê¤Ê¤Ë¤â¤Ê¤¤»þ¤Ï-1¡Ë
#deffunc get_pointing_rect array rects, local result
result = -1
foreach rects
point_rect rects( cnt ), mousex, mousey
if stat : result = cnt ; break
loop
return result
#global
*init
// Íð¿ô½é´ü²½
randomize
// Windows¥á¥Ã¥»¡¼¥¸³ä¤ê¹þ¤ß¼Â¹Ô»ØÄê
oncmd gosub *LButtonDown, WM_LBUTTONDOWN
oncmd gosub *LButtonUp, WM_LBUTTONUP
oncmd gosub *MouseMove, WM_MOUSEMOVE
// ¶ë·Á¤ò5¤ÄºîÀ®
repeat 5
w = rnd( 100 ) + 100 : h = rnd( 100 ) + 50
newmod rects, mdl_rect, rnd( ginfo_winx - w ), rnd( ginfo_winy - h ), w, h, rnd( 191 )
loop
// ¥Þ¥¦¥¹¥«¡¼¥½¥ë¤Î¼ïÎà¤òµÏ¿¤¹¤ëÊÑ¿ô¤ò½é´ü²½
cursor_type = IDC_ARROW
// ²èÌ̤ι¹¿·
gosub *renew_screen
//¢¥á¥¤¥ó¥ë¡¼¥×¤ÇWM_MOUSEMOVE¤ÈƱÍͤνèÍý¤ò¤¹¤ë¡£
*main
gosub *MouseMove
wait 1
goto *main
//
// ²èÌ̤ι¹¿·
*renew_screen
redraw 0
color 255, 255, 255 : boxf
foreach rects
draw_rect rects( cnt )
loop
redraw 1
return
//
// ¥Þ¥¦¥¹¤Îº¸¥Ü¥¿¥ó¤òÎ¥¤·¤¿»þ¤Î½èÍý
*LButtonUp
time_LButtonUp = (gettime(5)*60+gettime(6))*1000+gettime(7)
if time_LButtonUP - time_LButtonDown <= Duration_Click { //¥Þ¥¦¥¹¤ò²¡¤·²¼¤²¤¿¤¿»þ¹ï¡ÊÉáˤȾ夲¤¿»þ¹ï¡ÊÉáˤ¬Duration_Click°ÊÆâ¤Î»þ
setcolor_rect rects( pointing_rect ), rnd(191)
}
dragging = 0 // ¥É¥é¥Ã¥°½ªÎ»
return
//
// ¥Þ¥¦¥¹¤Îº¸¥Ü¥¿¥ó¤ò²¡¤·¤¿»þ¤Î½èÍý
*LButtonDown
if ( pointing_rect >= 0 ) {
// ¶ë·Á¤ò¥Ý¥¤¥ó¥È¤·¤Æ¤¤¤ë¾ì¹ç¤Ï¤½¤Î¶ë·Á¤ò¥É¥é¥Ã¥°¤¹¤ë
dx = mousex : dy = mousey
dragging = 1
time_LButtonDown = (gettime(5)*60+gettime(6))*1000+gettime(7)
}
return
//
// ¥Þ¥¦¥¹¤¬Æ°¤¤¤¿¤È¤¤Î½èÍý
*MouseMove
if ( pointing_rect >= 0 ) & ( cursor_type != IDC_HAND ) {
// ¶ë·Á¤Î¾å¤Ç¤Ï¥«¡¼¥½¥ë¤ò¼ê¤Î·Á¤ËÊѹ¹
cursor_type = IDC_HAND
gosub *ChangeCursor
}
if ( pointing_rect < 0 ) & ( cursor_type != IDC_ARROW ) {
// ¶ë·Á¤Î³°¤Ç¤Ï¥«¡¼¥½¥ë¤òÄ̾ï¤Î·Á¤ËÊѹ¹
cursor_type = IDC_ARROW
gosub *ChangeCursor
}
if dragging {
// ¥É¥é¥Ã¥°Ãæ¤Ê¤é¤Ð¶ë·Á¤ò°ÜÆ°
get_x rects( pointing_rect ), x
get_y rects( pointing_rect ), y
move_rect rects( pointing_rect ), x + mousex - dx, y + mousey - dy
dx = mousex : dy = mousey
} else {
// ¥É¥é¥Ã¥°Ãæ¤Ç¤Ê¤¤¤Ê¤é¤Ð¥Ý¥¤¥ó¥È¤·¤Æ¤¤¤ë¶ë·Á¤òÄ´¤Ù¤ë
get_pointing_rect rects
pointing_rect = stat
}
// ²èÌ̤ò¹¹¿·
gosub *renew_screen
return
//
// ¥Þ¥¦¥¹¥«¡¼¥½¥ë¤ÎÊѹ¹
*ChangeCursor
SetClassLong hwnd, -12, LoadCursor( cursor_type )
mouse // ¥Þ¥¦¥¹¥«¡¼¥½¥ë¤Î¹¹¿·¡Ê¤³¤ì¤¬¤Ê¤¤¤È¨ºÂ¤ËÈ¿±Ç¤µ¤ì¤Ê¤¤¡Ë
return