[RESOLVED] Have a mouse pointer change while inside a form?
Hi there, I am working on a program to help students with math, but for the younger students, they have a hard time seeing the small default mouse cursor. I have made one that is bigger, and easier to see, but I don't want it to interfere with the other windows program. So I was wondering if anyone knew of a way so that the mouse cursor could change while it is on the form of the math program, but go back to the default one outside of the window?
Your help is appreciated as always!
Thanks!
Re: Have a mouse pointer change while inside a form?
Code:
Form1.MouseIcon = LoadPicture("C:\Cursor.cur")
Form1.MousePointer = vbCustom
Re: Have a mouse pointer change while inside a form?
Thank you. I changed the top line to Main.MouseIcon = LoadPicture(App.Path & "\HAND.cur")
My form/main menu is called main, and the cursor is called HAND, but when I go to run the formload event I get the error "invalid picture", is there a specific size the cursor has to be?
Re: Have a mouse pointer change while inside a form?
What is the size and color depth of your cursor?
Re: Have a mouse pointer change while inside a form?
If those Mouse* properties do not work for you, then perhaps these will:
Code:
Private Const GCL_HCURSOR As Long = (-12&)
Private Declare Function LoadCursorFromFileW Lib "user32.dll" (ByVal lpFileName As Long) As Long
Private Declare Function SetClassLong Lib "user32.dll" Alias "SetClassLongW" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Sub Form_Load()
SetClassLong hWnd, GCL_HCURSOR, LoadCursorFromFileW(StrPtr(App.Path & "\HAND.cur"))
End Sub
The LoadCursorFromFile API also accepts animated cursors (*.ani), which VB doesn't support.
1 Attachment(s)
Re: Have a mouse pointer change while inside a form?
Animated might be cool, the kids would like it, but I'll start small. I have NO idea of the cursor, as I have no prog that can tell me the bit depth. It is one of the old Mario Paint Hands from the SNES game.
I attached it just in case you wanted to see it/ :)
Re: Have a mouse pointer change while inside a form?
IrfanView says your cursor is 32x32 pixels, with 32 bits per pixel. VB can't indeed load it. I believe VB's limited to just 256 colors (8 bpp). But the good news is that the LoadCursorFromFile API successfully loads your cursor and SetClassLong sets it as the Form's cursor onwards.
Re: Have a mouse pointer change while inside a form?
OH this is wonderful, the kids are going to go nuts for this stuff! Thank you!
That's ok, I don't need the cursor to change once the program is running, just something (and I might make it larger too), so the students can see it easier.
I am not sure what you mean by that LoadCursorFromFile will allow me to use ani files, but VB won't? How can LoadCursorFromFile use it if VB itself wont? :)
Re: [RESOLVED] Have a mouse pointer change while inside a form?
That's because VB internally uses the Windows API for just about anything it does. But VB probably never intended to support animated cursors even though Windows supports it.
Re: [RESOLVED] Have a mouse pointer change while inside a form?
I see. Thank you for the clarification. I was wondering, I know this is not exactly on topic, but if I make a new mouse cursor in eps format. Is there a program that could convert it to .cur?
:)