[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?
On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
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?
On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
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.
On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
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.
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.
On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
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.
On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
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?