Results 1 to 6 of 6

Thread: mousecursor - invisible

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2000
    Posts
    2
    I need af mousepointer which is invisible (lookthruable)- can anyone point me in the right direction?
    I would like to hide the mousecursor when it is over a form.

    best regards
    Jakob

  2. #2
    Guest
    Use the ShowCursor API.
    Code:
    Private Declare Function ShowCursor Lib "user32" (ByVal bShow As Long) As Long
    
    Private Sub cmdHideCursor_Click()
        ShowCursor False   'Hide the cursor
    End Sub
    
    Private Sub cmdShowCursor_Click()
        ShowCursor True    'Show the cursor
    End Sub

  3. #3
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221

    no need for invisible mousepointers

    Just tested it and it works. Place a timer with interval 100 on the form. Paste this code and run.
    Code:
    Private Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, ByVal yPoint As Long) As Long
    Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
    Private Declare Function ShowCursor Lib "user32" (ByVal bShow As Long) As Long
    Private Type POINTAPI
            x As Long
            y As Long
    End Type
    
    Private Sub Timer1_Timer()
        Static over As Boolean
        Dim mouse As POINTAPI
        GetCursorPos mouse
        If WindowFromPoint(mouse.x, mouse.y) = hWnd Then
            If Not over Then
                over = True
                ShowCursor 0
            End If
        Else
            If over Then
                over = False
                ShowCursor 1
            End If
        End If
    End Sub
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  4. #4
    Fanatic Member Mad Compie's Avatar
    Join Date
    Aug 2000
    Location
    Kuurne (Belgium)
    Posts
    553
    Hey guys, remember thta our friend Windows keeps track of the number of 'shows'.
    So, if you do twice a ShowCursor 1&, you also should execute twice ShowCursor 0&.
    Sometimes this is very annoying if we are debugging code, because the mouse cursor could be invisible!

  5. #5
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Thats correct Compie, well my code should cope with that: The over boolean let's you know what state the cursor is in, and it only reacts if the state is changed.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  6. #6
    Fanatic Member Mad Compie's Avatar
    Join Date
    Aug 2000
    Location
    Kuurne (Belgium)
    Posts
    553
    Absolutely, Keda! I was just mentioning it to Jaks.

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