就这么几句话,总是不太好用。请dx指点。
if (xpos>=p_2.x and xpos<=p_2.x+p_2.width) and (ypos>=p_2.y and ypos<=p_2.y+p_2.height) then
p_2.visible=false;
else
p_2.visible=true;
end if
...全文
367打赏收藏
一个简单的鼠标事件问题
就这么几句话,总是不太好用。请dx指点。 if (xpos>=p_2.x and xpos=p_2.y and ypos<=p_2.y+p_2.height) then p_2.visible=false; else p_2.visible=true; end if
你把代码稍微改一下,比如说写到一个command button的mousemove事件里
先声明实例变量picturebutton_tr和local external functions
IF picturebutton_tr=True THEN
SetCapture(Handle(This))
Picturebutton_tr=False
this.visible = false
ELSEIF (Xpos<0 Or Ypos<0 Or Xpos>This.Width Or Ypos>This.Height) THEN
ReleaseCapture()
Picturebutton_tr=True
this.visible = true
END IF
定义实例变量:
Boolean Picturebutton_tr=true
声明函数:
FUNCTION ulong SetCapture(ulong hwnd) LIBRARY "user32.dll"
//跟踪鼠标
FUNCTION ulong ReleaseCapture() LIBRARY "user32.dll"
//释放鼠标
pbm_mousermove:
IF picturebutton_tr=True THEN
SetCapture(Handle(This))
Picturebutton_tr=False
ELSEIF (Xpos<0 Or Ypos<0 Or Xpos>This.Width Or Ypos>This.Height) THEN
ReleaseCapture()
Picturebutton_tr=True
END IF