vb 调用.ani做鼠标(不同的控件调用不同的.ani文件,包括窗体本身)


ani比较复杂,vb默认只能使用 ico和cur =.= (不知道敬谈你是不是会弄这个,再罗索几句吧, Mousepointer设为 99 (custom) ,之后 MouseICON设置你想自定义的光标)
用ani得借 api
新建一个工程,在form上拖一个picturebox来( picturebox1)
弄两个 ani文件,放在你代竖稿兄码目录下,改成 1.ani 2.ani

Option Explicit
Private Const GCL_HCURSOR& = (-12)

Private Declare Function SetClassLong& Lib "user32" Alias "SetClassLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long)
Private Declare Function LoadCursorFromFile& Lib "user32" Alias "LoadCursorFromFileA" (ByVal lpFileName As String)

Private NewCursor1 As Long
Private OldCursor1 As Long
Private NewCursor2 As Long
Private OldCursor2 As Long

Private Sub Form_Load()
NewCursor1 = LoadCursorFromFile(App.Path & "\1.ani"余袭)
OldCursor1 = SetClassLong(Me.hWnd, GCL_HCURSOR, NewCursor1)
NewCursor2 = LoadCursorFromFile(App.Path & "\2.ani")
OldCursor2 = SetClassLong(Picture1.hWnd, GCL_HCURSOR, NewCursor2)
End Sub

Private Sub Form_Unload(Cancel As Integer)
SetClassLong Me.hWnd, GCL_HCURSOR, OldCursor1
SetClassLong Picture1.hWnd, GCL_HCURSOR, OldCursor2
End Sub