dcsimg
Results 1 to 7 of 7

Thread: Mouse Disappears - How to Reset in App

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2017
    Posts
    409

    Mouse Disappears - How to Reset in App

    I've got an MDI program
    Every once in awhile my mouse disappears (not visible) and I cannot get it back for use in "this" App.
    The Mouse still exists, as is is available for other Applications when it moves off the MDI.
    I've created a menu option to try and recover the mouse with this code but it does NOT work.

    Code:
       Call API >> ShowCursor(True)
       lngReturn = SetSystemCursor(CopyIcon(ghDefaultCursor), OCR_NORMAL)
    Rarely use DoEvents, but would a DoEvents before and/or after help ??

    Any suggestions on how to locate the problem code and/or a RESET solution.
    Last edited by vb6forever; Aug 6th, 2019 at 04:08 PM.

  2. #2
    Frenzied Member
    Join Date
    Feb 2017
    Posts
    1,786

    Re: Mouse Disappears - How to Reset in App

    Code:
    Private Declare Function ShowCursor Lib "user32" (ByVal bShow As Long) As Long
    
    Private Property Let ShowMouse(nShow As Boolean)
        If nShow Then
            Do Until ShowCursor(1) >= 0
            Loop
        Else
            Do Until ShowCursor(0) < 0
            Loop
        End If
    End Property
    
    Private Property Get ShowMouse() As Boolean
        ShowCursor (0)
        ShowMouse = ShowCursor(1) >= 0
    End Property
        
    Private Sub Command1_Click()
        ShowMouse = Not ShowMouse
    End Sub

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2017
    Posts
    409

    Re: Mouse Disappears - How to Reset in App

    Eduardo:
    Thanks for responding.
    Interesting solution to make multiple calls to ShowCursor.
    Only question is whether one may get locked into that loop without an exit.

  4. #4
    Frenzied Member
    Join Date
    Feb 2017
    Posts
    1,786

    Re: Mouse Disappears - How to Reset in App

    Quote Originally Posted by vb6forever View Post
    Eduardo:
    Thanks for responding.
    Interesting solution to make multiple calls to ShowCursor.
    Only question is whether one may get locked into that loop without an exit.
    No, it will always stop when crossing 0.
    The documentation in MSDN says:

    What it does:
    This function sets an internal display counter that determines whether the cursor should be displayed. The cursor is displayed only if the display count is greater than or equal to 0. If a mouse is installed, the initial display count is 0. If no mouse is installed, the display count is –1.
    Input parameter bShow:
    If bShow is TRUE, the display count is incremented by one. If bShow is FALSE, the display count is decremented by one.
    Return Value:
    The return value specifies the new display counter.

  5. #5
    Frenzied Member
    Join Date
    Apr 2012
    Posts
    1,098

    Re: Mouse Disappears - How to Reset in App

    What Eduardo suggest should work, of course, but I'd be curious to find out why the mousepointer is disappearing in the first place, if I were you...
    If you don't know where you're going, any road will take you there...

    My VB6 love-children: Vee-Hive and Vee-Launcher

  6. #6
    Frenzied Member
    Join Date
    Feb 2017
    Posts
    1,786

    Re: Mouse Disappears - How to Reset in App

    Quote Originally Posted by ColinE66 View Post
    I'd be curious to find out why the mousepointer is disappearing in the first place, if I were you...
    agree

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2017
    Posts
    409

    Re: Mouse Disappears - How to Reset in App

    Been working on trying to find that for sometime.
    Have some clues, occurs rarely, so tough to pinpoint.
    But we're all in agreement on need to locate.

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width