Come caricare un cursore animato in VB.NET

Qui di seguito vi posto un piccolo esempio di come utilizzare i cursori animati in VB.NET,unico problema che non sono riuscito a risolvere è come carica il cursore da una risorsa.Ogni suggerimento e ben accetto.

Private Const IMAGE_CURSOR As Int32 = 2

Private Const LR_LOADFROMFILE As Int32 = &H10

Private Declare Function LoadImage Lib "user32.dll" Alias "LoadImageA" (ByVal hInst As Int32, ByVal lpsz As String, ByVal un1 As Int32, ByVal n1 As Int32, ByVal n2 As Int32, ByVal un2 As Int32) As IntPtr

Private Declare Function CloseHandle Lib "kernel32.dll" (ByVal hObject As IntPtr) As Int32

Public Function LoadAniCursor(ByVal file As String) As Cursor

Dim ptrCursor As IntPtr

ptrCursor = LoadImage(0, file, IMAGE_CURSOR, 0, 0, LR_LOADFROMFILE)

If Not ptrCursor.Equals(IntPtr.Zero) Then

LoadAniCursor = New Cursor(ptrCursor)

CloseHandle(ptrCursor)

End If

End Function

 

Print | posted on domenica 19 giugno 2005 00:06