[RESOLVED] Animated cursors
i found these function in net for read animated cursors, but the real one change the system cursor. but i wanted put(draw) the subimages in a picturebox array.
in my new changes i have incompleted DrawIconEx(i don't know use these API function) arguments.
and i don't know if there is more errors.
can anyone help me finish these function?
Code:
Option Explicit
Private Declare Function LoadCursorFromFile Lib "user32" Alias _
"LoadCursorFromFileA" (ByVal lpFileName As String) As Long
Private Declare Function GetCursor Lib "user32" () As Long
Private Declare Function CopyIcon Lib "user32" (ByVal hcur As Long) As Long
Private mlngOldCursor As Long, lngNewCursor As Long
Private Declare Function DrawIconEx Lib "user32" (ByVal hdc As Long, ByVal xLeft As Long, ByVal yTop As Long, ByVal hIcon As Long, ByVal cxWidth As Long, ByVal cyWidth As Long, ByVal istepIfAniCur As Long, ByVal hbrFlickerFreeDraw As Long, ByVal diFlags As Long) As Long
Public Sub AnimatedCursor(AniFilePath As String, picDestany As Variant)
Static i As Long
i = i + 1
'Create a copy of the current cursor, 'for Windows NT compatibility
mlngOldCursor = CopyIcon(GetCursor())
'Check the passed string, if it contains
'a solid file path, then load the cursor
'from file. If not, add the App.Path, '*then* load cursor...
If InStr(1, AniFilePath, "\") Then
lngNewCursor = LoadCursorFromFile(AniFilePath)
Else
lngNewCursor = LoadCursorFromFile(App.Path & _
"\" & AniFilePath)
End If 'Activate the cursor
Load picDestany(i)
drawiconex picDestany(i).hdc,0,0, lngNewCursor,
End Sub
thanks
Re: [RESOLVED] Animated cursors
Re: [RESOLVED] Animated cursors
thanks for advice.. thank you
Re: [RESOLVED] Animated cursors
Code:
Option Explicit
Private Declare Function LoadCursorFromFile Lib "user32" Alias _
"LoadCursorFromFileA" (ByVal lpFileName As String) As Long
Private Declare Function DrawIconEx Lib "user32" _
(ByVal hdc As Long, ByVal xLeft As Long, _
ByVal yTop As Long, ByVal hIcon As Long, _
ByVal cxWidth As Long, ByVal cyWidth As Long, _
ByVal istepIfAniCur As Long, ByVal hbrFlickerFreeDraw As Long, _
ByVal diFlags As Long) As Long
Private Declare Function DestroyIcon Lib "user32" (ByVal hIcon As Long) As Long
Const DI_NORMAL = &H3
Dim hCursor As Long
Code:
Private Sub cmdSelect_Click()
Timer1.Enabled = False
CommonDialog1.Filter = "Animated Cursors(*.ani)|*.ani"
CommonDialog1.ShowOpen
If hCursor > 0 Then
DestroyIcon hCursor
hCursor = 0
End If
hCursor = LoadCursorFromFile(CommonDialog1.FileName)
If hCursor > 0 Then Timer1.Enabled = True
End Sub
Private Sub Form_Unload(Cancel As Integer)
Timer1.Enabled = False
If hCursor > 0 Then
DestroyIcon hCursor
hCursor = 0
End If
Set Form1 = Nothing
End Sub
Private Sub Timer1_Timer()
Static i As Integer
AnimatedBox.Picture = Nothing
If DrawIconEx(AnimatedBox.hdc, 0, 0, hCursor, 32, 32, i, 0, DI_NORMAL) > 0 Then
i = i + 1
Else
i = 0: Timer1_Timer
End If
End Sub
Re: [RESOLVED] Animated cursors
but now i have a question: i put the autosize property picturebox to true, but when the image is draw the size of picturebox isn't configured. why?
Re: [RESOLVED] Animated cursors
The code in your zip file doesn't auto size the picture either, picture boxes only auto resize when a file is loaded or pasted in while in the IDE, not when drawn to.
Re: [RESOLVED] Animated cursors
but can you help me how see the image size?
thank you very much
Re: [RESOLVED] Animated cursors
Not sure, I thought they were all 32x32 pixels?
Update my code, see post #7 above, I set the drawicon code to draw em at 32,32 anyway, you can change that back to 0,0..
Re: [RESOLVED] Animated cursors
honestly i don't know if they are -all animated cursors- 32X32 image size.
yes i can change the image size, but i wanted to know the original size...
but thanks for everything