如何捕捉到鼠标单击事件和其位置(要源代码)

limzi 2003-03-09 05:43:32

解决了马上给分
...全文
162 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
unrknight 2003-05-21
  • 打赏
  • 举报
回复
什么样的效果?
limzi 2003-05-21
  • 打赏
  • 举报
回复
怎么没有我要的呢
pcwak 2003-03-14
  • 打赏
  • 举报
回复
Type POINTAPI
x As Long
y As Long
End Type
Public Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Public Const HWND_TOPMOST = -1
Public Const SWP_NOMOVE = &H2
Public Const SWP_NOSIZE = &H1
Public Const SWP_NOZORDER = &H8

Public Sub SetFormTopmost(TheForm As Form)
SetWindowPos TheForm.hwnd, HWND_TOPMOST, 0, 0, 0, 0, _
SWP_NOZORDER + SWP_NOMOVE + SWP_NOSIZE
End Sub






Dim z As POINTAPI
Public fx
Public fy
Public a
Private Sub Form_Load()
Form1.Left = 200
Form1.Top = 200
fx = 1
fy = 1
a = 1
End Sub

Private Sub Timer1_Timer()
GetCursorPos z
If Form1.Left < z.x * 200 / 13 Then
fx = 1
End If
If Form1.Top < z.y * 200 / 13 Then
fy = 1
End If
If Form1.Left > z.x * 200 / 13 Then
fx = -1
End If
If Form1.Top > z.y * 200 / 13 Then
fy = -1
End If
If fx = 1 Then
Form1.Left = Form1.Left + 50
End If
If fy = 1 Then
Form1.Top = Form1.Top + 50
End If
If fx = -1 Then
Form1.Left = Form1.Left - 50
End If
If fy = -1 Then
Form1.Top = Form1.Top - 50
End If
If z.x * 200 / 13 > Form1.Left And z.x * 200 / 13 < Form1.Left + 480 Then
If z.y * 200 / 13 > Form1.Top And z.y * 200 / 13 < Form1.Top + 495 Then
Timer1.Enabled = False
SetFormTopmost Form1

v = MsgBox("你一百分是我的了", vbOKOnly, "结帐吧")
If v = vbOK Then
End
End If
End If
End If
End Sub
pcwak 2003-03-14
  • 打赏
  • 举报
回复
把你的信箱留下,我想要你这一百分,我给你个例子
limzi 2003-03-12
  • 打赏
  • 举报
回复
TO:各位帅哥
不对不对,我要的是记录的是程序外面的,就是系统的单击事件,而不是是在程序里面。
dsclub 2003-03-10
  • 打赏
  • 举报
回复
用VB就是楼上几位说的,亦可WM_LBUTTONDOWN、WM_LBUTTONUP消息
liberte 2003-03-10
  • 打赏
  • 举报
回复
mousedown
chenyu5188 2003-03-10
  • 打赏
  • 举报
回复
用鼠标单击事件(MouseDown事件)。
具体代码用northwolves(野性的呼唤)的。
kmcyz 2003-03-10
  • 打赏
  • 举报
回复
MouseMove事件
northwolves 2003-03-10
  • 打赏
  • 举报
回复
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then MsgBox "您单击了鼠标左键" & vbCrLf & " X=" & X & ",Y=" & Y
If Button = 2 Then MsgBox "您单击了鼠标右键" & vbCrLf & " X=" & X & ",Y=" & Y
End Sub
Girl1983 2003-03-09
  • 打赏
  • 举报
回复
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
MsgBox "怎么动鼠标了?X=" & X & ",Y=" & Y, vbQuestion + vbOKOnly
End Sub

7,762

社区成员

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

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