捕捉鼠标的问题?

SnakeFF 2002-09-13 09:04:09
控件怎样才能捕捉到鼠标进入和出去???
请高手指教!!!
...全文
37 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
hanyongbinlq 2002-09-14
  • 打赏
  • 举报
回复
event_id:pbm_mousemove
在这个自定义事件中编写代码
liuyxit 2002-09-14
  • 打赏
  • 举报
回复
定义API:
FUNCTION ulong SetCapture(ulong hwnd) LIBRARY "user32.dll"
FUNCTION ulong ReleaseCapture() LIBRARY "user32.dll"
在mousemove事件中:
boolean ib_mousein
ib_mousein = (xpos>0 and ypos>0 and xpos<width and ypos<height)
if ib_mousein then
SetCapture( handle( this ) )
//这里写鼠标进入控件的
else
ReleaseCapture( )
//这里写鼠标离开的
end if
hjd_cw 2002-09-14
  • 打赏
  • 举报
回复
win32 api:
TrackMouseEvent
该函数可以 生成 WM_MOUSEIN 和 WM_MOUSELEAVE 事件
lkaiwen 2002-09-14
  • 打赏
  • 举报
回复
同上
pufan 2002-09-13
  • 打赏
  • 举报
回复
mousemove 事件中写程序
balloonman2002 2002-09-13
  • 打赏
  • 举报
回复
也可在控件的MOUSEMOVE和FORM的MOUSEMOVE事件里面分别编程,其实FORM的MOUSEMOVE事件就是控件的MOUSEOUT事件,:)
balloonman2002 2002-09-13
  • 打赏
  • 举报
回复
Private Type POINTAPI
X As Long
Y As Long
End Type
Private Declare Function SetCapture Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Dim Pt As POINTAPI
Private Sub Form_Load()
'redirect all mouse input to this form
SetCapture Me.hwnd
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
ReleaseCapture
SetCapture Me.hwnd
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
'Get the current cursor position
GetCursorPos Pt
Me.CurrentX = 0
Me.CurrentY = 0
'Clear the screen
Me.Cls
Me.Print "Cursor position:"
'Print the mouse coördinates to the form
Me.Print "X:" + Str$(Pt.X) + " Y:" + Str$(Pt.Y)
Me.Print " (Press ALT-F4 to unload this form)"
SetCapture Me.hwnd
End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
ReleaseCapture
SetCapture Me.hwnd
End Sub

1,077

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder 相关问题讨论
社区管理员
  • 基础类社区
  • WorldMobile
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧