Results 1 to 4 of 4

Thread: Lock the mouse...

  1. #1

    Thread Starter
    Member
    Join Date
    Jul 2000
    Location
    LAVAL ( FRANCE )
    Posts
    32

    Unhappy

    I'd like to know if it's possible to lock the mouse in a form. I mean : I'd like the mouse cursor to be invisible ( i know the code ) and i'd like the user can only use the keyboard... how can i do ??

    Thanks

    COSIDUS

  2. #2
    Guest
    To disable the Mouse
    Code:
    Shell "rundll32 mouse,disable"
    To Hide/Show the cursor:
    Code:
    Private Declare Function ShowCursor Lib "user32" (ByVal bShow As Long) As Long
    
    Private Sub Command1_Click()
        'Hide the cursor
        ShowCursor 0
    End Sub
    
    Private Sub Command2_Click()
        'Show the cursor
        ShowCursor 1
    End Sub

  3. #3
    New Member
    Join Date
    Aug 2000
    Location
    Austria
    Posts
    9

    lock one mouse button?

    and how can i lock one mouse button?
    i would like that only the left button works!
    is that possible?

    thank you...

  4. #4
    Guest
    If your form does not have a popup menu, why not try your first suggestion: lock the mouse on the form.

    Code:
    Declare Function ClipCursor Lib "user32" (lpRect As Any) As Long
    
    Type RECT
      Left As Long
      Top As Long
      Right As Long
      Bottom As Long
    End Type
    
    Public Sub DisableTrap(CurForm As Form)
    Dim erg As Long
    'Declare a variable for the procedure
    'to set the new coordinates
    Dim NewRect As RECT
    CurForm.Caption = "Mouse released"
    'Set the new coordinates to full screen
    With NewRect
      .Left = 0&
      .Top = 0&
      .Right = Screen.Width / Screen.TwipsPerPixelX
      .Bottom = Screen.Height / Screen.TwipsPerPixelY
    End With
    
    erg& = ClipCursor(NewRect)
    End Sub
    
    Public Sub EnableTrap(CurForm As Form)
    Dim X As Long, Y As Long, erg As Long
    'Declare a variable for the procedure
    'to set the new coordinates
    Dim NewRect As RECT
    'Get the TwipsperPixel
    'The Form's ScaleMode must be set to Twips!!!
    X& = Screen.TwipsPerPixelX
    Y& = Screen.TwipsPerPixelY
    CurForm.Caption = "Mouse trapped"
    'Set the Cursor-Region to the coordinates
    'of the form
    With NewRect
      .Left = CurForm.Left / X&
      .Top = CurForm.Top / Y&
      .Right = .Left + CurForm.Width / X&
      .Bottom = .Top + CurForm.Height / Y&
    End With
    erg& = ClipCursor(NewRect)
    End Sub
    
    Usage:
    
    EnableTrap Me
    
    DisableTrap Me
    
    'Remember, put a DisableTrap Me in the Form_Unload event.


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