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
Printable View
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
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. ;)
http://www.vbforums.com/showthread.php?t=235194Code: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
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
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 !
Horazio,
Could you kindly share your code please? I too would like to make my own screensaver but don't know where to start!
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
Thanks, buddy, that helped a lot.
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?
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. ;)
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?