VBGood网站全文搜索 Google

搜索VBGood全站网页(全文搜索)
首页 - 经验之谈 - 显示动画光标实例
发表评论(0)作者:不详, 平台:VB6.0+Win98, 阅读:9966, 日期:2001-01-07
显示动画光标实例
--------------------------------------------------------------------------------

`说明:表单一个;命令按钮两个为CmdShow标题为"显示动画光标"和CmdRestore标题为"恢复原来光标";
`      动画光标一个为Global.Ani

Option Explicit
Dim mhBaseCursor As Long     `原始光标
Dim mhAniCursor As Long    `安装后的光标

Const GCL_HCURSOR = (-12)

Private Declare Function DestroyCursor Lib "user32" (ByVal hCursor As Long) As Long
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 Declare Function GetClassLong Lib "user32" Alias "GetClassLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long

Private Sub CmdShow_Click()

Dim lResult As Long

mhAniCursor = LoadCursorFromFile(App.Path + "\Globe.ani") `安装动画光标文件

lResult = SetClassLong((Me.hwnd), GCL_HCURSOR, mhAniCursor)

End Sub

Private Sub CmdRestore_Click()

Dim lResult As Long

lResult = SetClassLong((Me.hwnd), GCL_HCURSOR, mhBaseCursor) `恢复光标
lResult = DestroyCursor(mhAniCursor)

End Sub

Private Sub Form_Load()

Dim lResult As Long
mhBaseCursor = GetClassLong((Me.hwnd), GCL_HCURSOR) `给出当前光标

End Sub