Results 1 to 27 of 27

Thread: lock windows

Hybrid View

  1. #1

  2. #2

    Thread Starter
    Lively Member
    Join Date
    Jan 2009
    Posts
    126

    Re: lock windows

    o.k.
    thanx
    i have seen that you can confine the mouse tho the form...
    my ? is can i stop the mouse from leaving the fiscal edge of the form i.e. if it arrives at the edge, it stops!


    tahnx in advance
    MrSmither
    he is a good friend that speaks well of us behind our backs

  3. #3
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: lock windows

    Here's an example from the API Guide that uses the ClipCursor API do do that.

    Code:
    Private Type RECT
        left As Long
        top As Long
        right As Long
        bottom As Long
    End Type
    Private Type POINT
        x As Long
        y As Long
    End Type
    Private Declare Sub ClipCursor Lib "user32" (lpRect As Any)
    Private Declare Sub GetClientRect Lib "user32" (ByVal hWnd As Long, lpRect As RECT)
    Private Declare Sub ClientToScreen Lib "user32" (ByVal hWnd As Long, lpPoint As POINT)
    Private Declare Sub OffsetRect Lib "user32" (lpRect As RECT, ByVal x As Long, ByVal y As Long)
    Private Sub Form_Load()
        'KPD-Team 1999
        'URL: http://www.allapi.net/
        'E-Mail: [email protected]
        Command1.Caption = "Limit Cursor Movement"
        Command2.Caption = "Release Limit"
    End Sub
    Private Sub Command1_Click()
        'Limits the Cursor movement to within the form.
        Dim client As RECT
        Dim upperleft As POINT
        'Get information about our wndow
        GetClientRect Me.hWnd, client
        upperleft.x = client.left
        upperleft.y = client.top
        'Convert window coördinates to screen coördinates
        ClientToScreen Me.hWnd, upperleft
        'move our rectangle
        OffsetRect client, upperleft.x, upperleft.y
        'limit the cursor movement
        ClipCursor client
    End Sub
    Private Sub Command2_Click()
        'Releases the cursor limits
        ClipCursor ByVal 0&
    End Sub
    Private Sub Form_Unload(Cancel As Integer)
        'Releases the cursor limits
        ClipCursor ByVal 0&
    End Sub

  4. #4
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: lock windows

    Quote Originally Posted by mr smither View Post
    o.k.
    thanx
    i have seen that you can confine the mouse tho the form...
    my ? is can i stop the mouse from leaving the fiscal edge of the form i.e. if it arrives at the edge, it stops!


    tahnx in advance
    MrSmither
    If you are trying to prevent users from using the mouse to access any other windows, then that could do it. But they will still be able to use the keyboard to maneuver around, including Ctrl+Alt+Del to access task manager and shut your app down so they can get their mouse back -- that's what I'd do.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  5. #5
    coder. Lord Orwell's Avatar
    Join Date
    Feb 2001
    Location
    Elberfeld, IN
    Posts
    7,628

    Re: lock windows

    Quote Originally Posted by LaVolpe View Post
    If you are trying to prevent users from using the mouse to access any other windows, then that could do it. But they will still be able to use the keyboard to maneuver around, including Ctrl+Alt+Del to access task manager and shut your app down so they can get their mouse back -- that's what I'd do.
    that's also stoppable with a keyboard hook. There's code samples on the forum. But (especially if you are using a twain device) if for some reason it locks your program up, the user will have to reset the computer.

    Why you would want your program to access their scanner is beyond me, unless it's a scanning program. In that case, you'd be better off with a progress bar. (i am assuming here. you said scaner, and who knows what you really meant)
    My light show youtube page (it's made the news) www.youtube.com/@lightsofelberfeld
    Contact me on the socials www.facebook.com/lordorwell

  6. #6
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: lock windows

    Quote Originally Posted by Lord Orwell View Post
    Why you would want your program to access their scanner is beyond me, unless it's a scanning program. In that case, you'd be better off with a progress bar. (i am assuming here. you said scaner, and who knows what you really meant)
    I would also ask the question, why would you want to prevent the user from accessing their computer while this app is accessing the scanner? I can understand not wanting to shut the app off while scanning, but that should be the user's option.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

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