VB如何判断鼠标是否按下

如何判断鼠标当前是否处于按住状态请不要用到MouseDown事件... 如何判断鼠标当前是否处于按住状态
请不要用到MouseDown事件
展开
 我来答
匿名用户
2013-08-12
展开全部
API函数
Option Explicit

Public Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Public Const GWL_WNDPROC = (-4)
Public Const WM_USER = &H400
Public Const WM_MBUTTONDBLCLK = &H209
Public Const WM_MBUTTONDOWN = &H207
Public Const WM_MBUTTONUP = &H208
Public Const WM_LBUTTONUP = &H202
Public Const WM_LBUTTONDOWN = &H201
Public Const WM_LBUTTONDBLCLK = &H203
Public Const WM_RBUTTONDBLCLK = &H206
Public Const WM_RBUTTONDOWN = &H204
Public Const WM_RBUTTONUP = &H205
Public OldWindowProc As Long
Public Myform As Form
Public AA As Long
Public Sub CheckMouse(A As Form)
Set Myform = A
OldWindowProc = GetWindowLong(Myform.hwnd, GWL_WNDPROC)
SetWindowLong Myform.hwnd, GWL_WNDPROC, AddressOf NewWindowProc
End Sub
Public Function NewWindowProc(ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Select Case Msg
Case WM_LBUTTONUP
Form1.Text1.Text = Form1.Text1.Text + "LBUTTONUP"
Case WM_LBUTTONDOWN
Form1.Text1.Text = "LBUTTONDOWN"
Case WM_LBUTTONDBLCLK
Form1.Text1.Enabled = True
Case WM_RBUTTONDBLCLK
Form1.Text1.Enabled = False
Case WM_RBUTTONDOWN
Form1.Text1.Text = "RBUTTONDOWN"
Case WM_RBUTTONUP
Form1.Text1.Text = "RBUTTONUP"
End Select
NewWindowProc = CallWindowProc(OldWindowProc, hwnd, Msg, wParam, lParam)
End Function

ForM_load()
checkMouse form1
end sub
匿名用户
2013-08-12
展开全部
Private sub form_MOUSEdown(button as integer)
if button=1 then '1按住左键
Msgbox "你按住的为左键"
else
Msgbox "你按住的为右键"
END SUB
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式