判断鼠标停留 Picture控件一种思想Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Picture1.BackColor = &HFF0000
End Sub
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Picture1.BackColor = &H0
End Sub

解决方案 »

  1.   

    Option Explicit
    Private Declare Function SetCapture Lib "user32" (ByVal hWnd As Long) As Long
    Private Declare Function ReleaseCapture Lib "user32" () As LongPrivate Sub Command2_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
        Dim MouseOver As Boolean
        
        MouseOver = (0 <= X) And (X <= command2.Width) And (0 <= Y) And (Y <= command2.Height)
        If MouseOver Then
            ' MouseOver Event
            command2.Caption = "Over"
            SetCapture command2.hWnd
        Else
            ' MouseLeave Event
            command2.Caption = "Leave"
            ReleaseCapture
        End If
    End Sub
      

  2.   

    MOUSE离开了按钮不就到了其它的容器(比如窗体,框架)上了,这是看看MOUSE所在XY座标与控件的TOP,LEFT等属性相比一下不就可以了??
      

  3.   

    有一个变通的办法,加入窗体上只有两个控件form1,command1 可用如下代码:Private i As Boolean
    Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
      i = True
    End SubPrivate Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
      i = False
    End SubPrivate Sub Timer1_Timer()
       If i = True Then    '鼠标在按钮上
       End If
       If i = False Then   '鼠标不在按钮上
       End If
    End Sub
    '你的窗体一定不止两个控件,只要不是command1的mousemove事件,就将i赋值为false.
      

  4.   

    鼠标离开事件:MouseUP
    直接引用就可以了。
      

  5.   

    BigRichBigNoble(大富大贵)的解法是最经典的,也应该是可行的,qhzxcz(audio)也基本上可用,我以为.我用前者的方法
      

  6.   

    唉!
    只有对窗体的每个控件编程了!
    上面两个 API 什么功能?
    SetCapture
    ReleaseCapture
      

  7.   

    Private Declare Function SetCapture Lib "user32" (ByVal hwnd As Long) As Long
    Private Declare Function ReleaseCapture Lib "user32" () As LongPrivate Sub PicChangemain(sPic As PictureBox, X As Single, Y As Single)
    Dim MouseExit As BooleanMouseExit = (0 <= X) And (X <= sPic.Width) And (0 <= Y) And (Y <= sPic.Height)If MouseExit Then
    sPic.Picture = ImageHomesellT.ListImages(Val(sPic.Tag)).Picture
    SetCapture sPic.hwndElsesPic.Picture = ImageHomesell.ListImages(Val(sPic.Tag)).Picture
    ReleaseCapture
    End If
    End Sub
    这是一个图片按钮移到变化的过程用于MOSEMOVE中看看吧