可不可以在Label1_MouseDown中判断出鼠标左键是否按下或抬起。

xzp1030 2003-12-15 09:21:20
可不可以在Label1_MouseDown中判断出鼠标左键是否按下或抬起。
...全文
113 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
hhjjhjhj 2003-12-15
  • 打赏
  • 举报
回复
Private Sub Label1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim k As String
Select Case Button
Case 1
k = "左键按下了"
Case 2
k = "右键按下了"
Case Else
k = "没键按下"
End Select
k = k & Chr(10) & X & Chr(10) & Y
Label1.Caption = k

End Sub
xzp1030 2003-12-15
  • 打赏
  • 举报
回复
to:SoHo_Andy(冰) ( )
能给我讲解一下吗,为什么不行啊?
xzp1030 2003-12-15
  • 打赏
  • 举报
回复
我试了这种方法为什么不行啊,不明白,请高手指点。
Private Sub lblcaption_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim msg As Long
msg = X / Screen.TwipsPerPixelX
Select Case msg
Case WM_LBUTTONDOWN
mouseState = True
Case WM_LBUTTONUP
mouseState = False
End Select
End Sub
xzp1030 2003-12-15
  • 打赏
  • 举报
回复
我要在Label1_MouseMove 中直接判断行不行,有没有这种方法?不是在其它的地方。
我想解决的问题是:下面这个过程在不停的执行着,当鼠村移到label控件上,当鼠标按下赋一个变量为真,抬起是为假。

Private Sub tmrChkStatus_Timer()
Dim lonCStat As Long
Dim lonCurrhWnd As Long
tmrChkStatus.Enabled = False
lonCStat = GetCursorPos(mpoiCursorPos)
lonCurrhWnd = WindowFromPoint(mpoiCursorPos.X, mpoiCursorPos.Y)
If mbooButtonLighted = False Then
If lonCurrhWnd = UserControl.hWnd Then
mbooButtonLighted = True
If mmodButtonMode = [Text Only Mode] Then
UserControl.BackColor = molcSelColor
ElseIf mmodButtonMode = [Image Mode] Then
Set UserControl.Picture = mpicSelPicture
Else
ShowLine True
If mouseState Then '***********当鼠标在label上按下时***********
Call OnLable(0)
Else
Call OnLable(1) '*****当鼠标在label上抬起时,*****
End If
DoEvents
End If
End If
RaiseEvent StatusChanged(1)
Else
If lonCurrhWnd <> UserControl.hWnd Then
mbooButtonLighted = False
If mmodButtonMode = [Text Only Mode] Then
UserControl.BackColor = molcBackColor
ElseIf mmodButtonMode = [Image Mode] Then
UserControl.Picture = mpicPicture
Else
ShowLine False
DoEvents
End If
End If
RaiseEvent StatusChanged(0)
End If
tmrChkStatus.Enabled = True

End Sub

iandylove 2003-12-15
  • 打赏
  • 举报
回复
if button =2 then 左键按下 if button <> 2 then 左键没有按下
SoHo_Andy 2003-12-15
  • 打赏
  • 举报
回复
Label1_MouseDown 当鼠标按下操作时保存一个变量值为1
Label1_MouseUp 当鼠标抬起操作时保存这个变量值为0

Label1_MouseMove中判断变量值就知道左键是否按下
笨狗先飞 2003-12-15
  • 打赏
  • 举报
回复
那就看button的值是多少了好象1是左2是右
xzp1030 2003-12-15
  • 打赏
  • 举报
回复
注意:

我写错了,是Label1_MouseMove中判断出鼠标左键是否按下或抬起。
SoHo_Andy 2003-12-15
  • 打赏
  • 举报
回复
Label1_MouseDown 是鼠标按下操作

Label1_MouseUp 是鼠标抬起操作
笨狗先飞 2003-12-15
  • 打赏
  • 举报
回复
不知道是不是写程序都这么绕,
这个问题好象可以绕过去的,没必要这么做,要不然的话怕又是要弄个API的出来了

7,762

社区成员

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

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