Option Explicit 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.hWndElse Me.Caption = "退出了" Command1.BackColor = &H8000000F ReleaseCaptureEnd If End Sub
Option Explicit 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.hWndElse Me.Caption = "退出了" Command1.BackColor = &H8000000F ReleaseCapture --------------------------------------------- 这样做有Bug!
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.hWndElse
Me.Caption = "退出了"
Command1.BackColor = &H8000000F
ReleaseCaptureEnd If
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.hWndElse
Me.Caption = "退出了"
Command1.BackColor = &H8000000F
ReleaseCapture
---------------------------------------------
这样做有Bug!