最好有程序.
thanks!

解决方案 »

  1.   

    Option Explicit
    Private Type RECT
            Left As Long
            Top As Long
            Right As Long
            Bottom As Long
    End TypePrivate Declare Function ClipCursor Lib "user32" (lpRect As Any) As Long
    Private Sub Form_Load()
    Dim rscreen As RECT
    rscreen.Top = Form1.Top
    rscreen.Left = Form1.Left
    rscreen.Right = Form1.Width
    rscreen.Bottom = Form1.Height
    ClipCursor rscreen
    End Sub
      

  2.   

    Option Explicit
    '  声明类型
    Private Type RECT
            Left As Long
            Top As Long
            Right As Long
            Bottom As Long
    End Type
    '  声明函数
    Private Declare Function ClipCursor Lib "user32" (lpRect As Any) As LongDim Form_Rect As RECT'  限制鼠标在窗体内活动
    Private Sub Form_Load()
        With Form_Rect
            .Left = Me.Left \ Screen.TwipsPerPixelX
            .Top = Me.Top \ Screen.TwipsPerPixelY
            .Right = (Me.Left + Me.Width) \ Screen.TwipsPerPixelX
            .Bottom = (Me.Top + Me.Height) \ Screen.TwipsPerPixelY
        End With
        ClipCursor Form_Rect
        Release_Btn.Enabled = True
    End Sub'  解除鼠标限制
    Private Sub Release_Btn_Click()
        ClipCursor Form_Rect
        Release_Btn.Enabled = False
    End Sub'  退出之前确保解除鼠标限制
    Private Sub Exit_Btn_Click()
        If Release_Btn.Enabled = True Then
        '    Release_Btn_Click
        End If
        End
    End Sub