Results 1 to 10 of 10

Thread: [RESOLVED] How to hide mouse cursor (VB6)

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2006
    Location
    Paris
    Posts
    301

    Resolved [RESOLVED] How to hide mouse cursor (VB6)

    Hi
    I'm designing a screensaver, so I was wondering how to hide the mouse cursor.
    How can I do it ??(I prefer to avoid APIs so my screensaver will work on all platforms)

    Thanks

    H

  2. #2
    PowerPoster Keithuk's Avatar
    Join Date
    Jan 2004
    Location
    Staffordshire, England
    Posts
    2,236

    Re: How to hide mouse cursor (VB6)

    Well all the screensavers I have it uses the ShowCursor API it simple and easy to use. While you are debugging rem it out the hide else you will loose the mouse if errors crop up then back to VB.
    Code:
    Option Explicit
    
    Private Declare Function ShowCursor Lib "user32" (ByVal bShow As Long) As Long
    
    Private Sub Form_Load()
    
    ShowCursor False 'hide cursor
    
    End Sub
    
    Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    
    ShowCursor True 'show cursor
    
    End Sub
    http://www.vbforums.com/showthread.php?t=235194
    Keith

    I've been programming with VB for 25 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.

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

    Re: How to hide mouse cursor (VB6)

    And to piggyback on Keith's reply. Calls to ShowCursor accumulate. If you call it 10x with False, gotta call it 10x with true for example. The return value of the API will let you know the accumulative value and ideally, you want 0 as the return value when the cursor is to be shown
    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}

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2006
    Location
    Paris
    Posts
    301

    Re: [RESOLVED] How to hide mouse cursor (VB6)

    Thanks guys !!
    I used Keithuk's code and Lavolpe's comments were important also to understand its mechanics.
    Now I have my own screensaver, a digital clock . Just 24 KB !

  5. #5
    Junior Member
    Join Date
    Nov 2007
    Posts
    17

    Re: [RESOLVED] How to hide mouse cursor (VB6)

    Horazio,
    Could you kindly share your code please? I too would like to make my own screensaver but don't know where to start!

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2006
    Location
    Paris
    Posts
    301

    Re: [RESOLVED] How to hide mouse cursor (VB6)

    Trust me, it's so simple you dont even need to look at the code.
    Just remember:

    1) a screensaver is just an ordinary executable with SCR extension instead of EXE (u compile it normally and then u change its extension to SCR)
    2) windows maximized, on top, form with no borders
    3) it must self shut down when you click the mouse or press a key
    4) Add whatever u like ;-)

    Rock on

  7. #7
    Junior Member
    Join Date
    Nov 2007
    Posts
    17

    Re: [RESOLVED] How to hide mouse cursor (VB6)

    Thanks, buddy, that helped a lot.

  8. #8
    Junior Member
    Join Date
    Nov 2007
    Posts
    17

    Re: [RESOLVED] How to hide mouse cursor (VB6)

    Sorry to return to this, but I have one minor problem, though: how to include the interface with the user to set preferences and other settings? If there is another form, how do you decide when to launch which?

  9. #9
    PowerPoster Keithuk's Avatar
    Join Date
    Jan 2004
    Location
    Staffordshire, England
    Posts
    2,236

    Re: [RESOLVED] How to hide mouse cursor (VB6)

    Yes you can have an Options Form where you can set various settings for the app and save them to an ini file or the dirty registry.
    Keith

    I've been programming with VB for 25 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.

  10. #10
    Junior Member
    Join Date
    Nov 2007
    Posts
    17

    Re: [RESOLVED] How to hide mouse cursor (VB6)

    I guessed as much, but my question was: if the app will launch with the screensaver form and exit from there, how does a user ever get to the Options form?

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