VB按钮鼠标离开事件
VB窗体中有4个按钮,当鼠标指中按钮的时候就会变红,一离开按钮就马上恢复变蓝,希望那位高手给点代码指示!谢谢二楼的不错设置一下Command1属性style值就可以用了,...
VB窗体中有4个按钮,当鼠标指中按钮的时候就会变红,一离开按钮就马上恢复变蓝,希望那位高手给点代码指示!谢谢
二楼的不错设置一下Command1属性style值就可以用了,三楼的我试过,如果按钮多了效果就不好,就是在窗体上移动鼠标的时候,按钮好像在刷新是的,不够理想!谢谢 展开
二楼的不错设置一下Command1属性style值就可以用了,三楼的我试过,如果按钮多了效果就不好,就是在窗体上移动鼠标的时候,按钮好像在刷新是的,不够理想!谢谢 展开
4个回答
展开全部
添加一个按钮控件,先把你的按钮BackColor设置成 &H00FF0000&,Style设置城 Graphical,然后添加如下代码:
Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Command1.BackColor = &HFF&
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Command1.BackColor = &HFF0000
End Sub
Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Command1.BackColor = &HFF&
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Command1.BackColor = &HFF0000
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Declare Function SetCapture Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim MouseEnter As Boolean
MouseEnter = (0 <= X) And (X <= Command1.Width) And (0 <= Y) And (Y <= Command1.Height)
If MouseEnter Then
Me.Caption = "进入"
Command1.BackColor = &HFFC0FF
SetCapture Command1.hwnd
Else
Me.Caption = "退出"
Command1.BackColor = &H8000000F
ReleaseCapture
End If
End Sub
Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim MouseEnter As Boolean
MouseEnter = (0 <= X) And (X <= Command1.Width) And (0 <= Y) And (Y <= Command1.Height)
If MouseEnter Then
Me.Caption = "进入"
Command1.BackColor = &HFFC0FF
SetCapture Command1.hwnd
Else
Me.Caption = "退出"
Command1.BackColor = &H8000000F
ReleaseCapture
End If
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
就是在别的地方的moveover事件
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
你说的这个指中是按下去还是光标到上面?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询