当前位置:编程学习 > VB >>

如何将鼠标显示成动画鼠标?

 

 

 动画在 Windows 底下是.ani 格式的文件,要显示此类鼠标,首先要利用 LoadCursorFromFile API 载入 .ani 文件,然后利用 SetSystemCursor API 加以显示,细节如下:

 

声明:

Option Explicit

 

Const OCR_NORMAL = 32512

Const IDC_ARROW = 32512&

 

Private Declare Function LoadCursorFromFile Lib "user32" Alias _

  "LoadCursorFromFileA" (ByVal lpFileName As String) As Long

Private Declare Function LoadCursor Lib "user32" Alias "LoadCursorA" _

  (ByVal hInstance As Long, lpCursorName As Any) As Long modified

Private Declare Function SetSystemCursor Lib "user32" _

  (ByVal hcur As Long, ByVal id As Long) As Long

 

代码:

 

Dim hCursor As Long

 

hCursor = LoadCursorFromFile( 欲显示的 .ani 或 .cur 文件名称 )

Call SetSystemCursor(hCursor, OCR_NORMAL)

 

  若要将鼠标还原原状,则执行以下过程:

 

hCursor = LoadCursor(0&, ByVal IDC_ARROW)

Call SetSystemCursor(hCursor, OCR_NORMAL)

补充:软件开发 , Vb ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,