Results 1 to 4 of 4

Thread: trap mouse in a form

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2000
    Posts
    1,539

    Talking

    how can i make it so that the mouse cursor stays WITHIN a form, until that form is unloaded by clicking something withing that form?

  2. #2
    Frenzied Member
    Join Date
    Jun 2000
    Location
    East Providence, RI
    Posts
    1,715
    NXSupport - Your one-stop source for computer help

  3. #3

  4. #4
    Guest
    Try this: Needs 2 CommandButtons
    Code:
    Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
    Private Declare Function ClipCursor Lib "user32" (lpRect As Any) As Long
    Private Declare Function GetDesktopWindow Lib "user32" () As Long
    Private Type RECT
            Left As Long
            Top As Long
            Right As Long
            Bottom As Long
    End Type
    Dim W_RECT As RECT
    
    Private Sub Command1_Click()
        'Trap the cursor
        GetWindowRect Me.hwnd, W_RECT
        ClipCursor W_RECT
    End Sub
    
    Private Sub Command2_Click()
        'Untrap the cursor
        GetWindowRect GetDesktopWindow, W_RECT
        ClipCursor W_RECT
    End Sub
    
    Private Sub Form_Unload(Cancel As Integer)
        Call Command2_Click
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width