调用API函数,以下为一个例程,当鼠标移到按钮上时,按钮标题变为Welcome,移出时变为Hello
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)
With Command1 'Change this to the name of the control
If Button = 0 Then
If (X < 0) Or (Y < 0) Or (X > .Width) Or (Y > .Height) Then
'Mouse pointer is outside button, so let other controls receive
'mouseevents too:
ReleaseCapture
Command1.Caption = "Hello"
' 放入鼠标离开的代码
Else
' Mouse pointer is over button, so we'll capture it, thus
' we'll receive mouse messages even if the mouse pointer is
' not over the button
SetCapture .hWnd
Command1.Caption = "Welcome"
' 放入鼠标进入的代码
End If
End If
End With
End Sub
楼主你是不是遇到点出来的菜单怎么也不消失吧?
告诉你吧,这是一个BUG。没有办法的,除非使用其它方法。
你单击任务栏的任何地方都行(右键)