|
-
Aug 11th, 2000, 03:05 PM
#1
Thread Starter
Fanatic Member
Downloaded this programe that you create animated mouse icons can anyone tell me how to asign it to a click event?
Cheers
Spud
-
Aug 11th, 2000, 03:12 PM
#2
What do you mean by assigning it to a click event?
-
Aug 11th, 2000, 03:15 PM
#3
If you mean displaying it when a button is clicked, you can use the following code.
Insert code in a Form with a CommonDialog and a CommandButton
Code:
Private Declare Function LoadCursorFromFile Lib "User32" Alias "LoadCursorFromFileA" (ByVal lpFileName As String) As Long
Private Declare Function SetClassLong Lib "User32" Alias "SetClassLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Const GCL_HCURSOR = (-12)
Dim prevCur As Long
Dim MyCursor As Long
Private Sub Command1_Click()
Dim OpenFile As String
CommonDialog1.Filter = "Animated Cursors (*.ani)|*.ani"
CommonDialog1.ShowOpen
OpenFile = CommonDialog1.filename
MyCursor = LoadCursorFromFile(OpenFile)
prevCur = SetClassLong(Me.hwnd, GCL_HCURSOR, MyCursor)
End Sub
Private Sub Form_Unload(Cancel As Integer)
prevCur = SetClassLong(Me.hwnd, GCL_HCURSOR, hOldCursor)
End Sub
-
Aug 11th, 2000, 04:46 PM
#4
Thread Starter
Fanatic Member
Megatron I think Im doing somthing wrong with this part of the code can you help?
CommonDialog1.Filter = ("C:\My Documents\gdsm.ani")
Thanks again
Spud
-
Aug 11th, 2000, 05:01 PM
#5
The Filter is the type of files you want to open. Just leave it at CommonDialog1.Filter = "Animated Cursors (*.ani)|*.ani" and it should work fine.
If you do not want to load it from the CommonDialog, then
use this line instead. MyCursor = LoadCursorFromFile("C:\My Documents\gdsm.ani")
-
Aug 11th, 2000, 08:48 PM
#6
Thread Starter
Fanatic Member
Thanks again Megatron thats it sorted now.
Cheers!
Spud
-
May 17th, 2002, 10:48 PM
#7
Junior Member
On mouseover
How would I alter the code so that an animated cursor is displayed when hovering over command1 only
 Help, is always appreciated.
-
May 17th, 2002, 11:13 PM
#8
This can do both Cursors and Icons:
VB Code:
Option Explicit
Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Command1.DragIcon = LoadPicture("C:\Program Files\Microsoft Visual Studio\Vfp98\FFC\Graphics\H_point.cur")
Command1.Drag vbBeginDrag
End Sub
Private Sub Command1_DragOver(Source As Control, X As Single, Y As Single, State As Integer)
If State = vbLeave Then
Command1.Drag vbEndDrag
End If
End Sub
-
May 17th, 2002, 11:32 PM
#9
Junior Member
That gives an Invalid Picture error
Doesn't that code do the same as Properties-Form1 Icon
It doesn't appear to work with .ani files.
 Help, is always appreciated.
-
May 17th, 2002, 11:37 PM
#10
Nope, it won't do .ani (Only Cursors and Icons)
I posted it incase u were just after Cursors
-
May 17th, 2002, 11:47 PM
#11
-
May 17th, 2002, 11:51 PM
#12
Try:
VB Code:
Option Explicit
Private Declare Function LoadCursorFromFile Lib "User32" Alias "LoadCursorFromFileA" (ByVal lpFileName As String) As Long
Private Declare Function SetClassLong Lib "User32" Alias "SetClassLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Const GCL_HCURSOR = (-12)
Dim prevCur As Long
Dim MyCursor As Long
Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
MyCursor = LoadCursorFromFile("C:\Windows\Cursors\Hourglas.ani")
prevCur = SetClassLong(Command1.hwnd, GCL_HCURSOR, MyCursor)
End Sub
Private Sub Form_Unload(Cancel As Integer)
prevCur = SetClassLong(Me.hwnd, GCL_HCURSOR, hOldCursor)
End Sub
The only problem at the moment is the error on unload.
I'm trying to fix it. The Cursor remains the HourGalss! (until u
close VB)
-
May 18th, 2002, 01:34 AM
#13
-
May 18th, 2002, 01:43 AM
#14
Good job 
Seems to work well!
Does anyone see a problem with it?
VB Code:
Option Explicit
Private Declare Function LoadCursorFromFile Lib "User32" Alias "LoadCursorFromFileA" (ByVal lpFileName As String) As Long
Private Declare Function SetClassLong Lib "User32" Alias "SetClassLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Const GCL_HCURSOR = (-12)
Dim prevCur As Long
Dim MyCursor As Long
Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
MyCursor = LoadCursorFromFile("C:\Windows\Cursors\Hourglas.ani")
prevCur = SetClassLong(Command1.hwnd, GCL_HCURSOR, MyCursor)
End Sub
-
Jul 16th, 2002, 11:57 AM
#15
Hyperactive Member
You were trying to set it to hOldCursor in form uload..which is never defined?
And I, for one, welcome our new insect overlords. I'd like to remind them as a trusted TV personality, I can be helpful in rounding up others to toil in their underground sugar caves.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|