让VB使用彩色及动画光标的方法

时间:2010-01-27 11:10:23  来源:第二电脑网  作者:第二电脑网

  第二电脑网导读:一个光标的变量值(jiu),为我们关闭程序时得以方便的恢复原始光标(jiu) 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, ByV...
  正文:

vb本身不支持彩色光标和动画光标,但可以通过调用Windows的API函数实现这一目的。这里用到两个API函数,LoadCursorFromFile用于装入新光标(xin),需要指明新光标的具体路径及文件名;SetClassLong用于设置使用新光标(xin)。这一函数使用时会返回一个代表前一个光标的变量值(jiu),为我们关闭程序时得以方便的恢复原始光标(jiu)
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
Dim xin As Long
Dim jiu As Long

Private Sub Form_Load()
xin = LoadCursorFromFile("C:WINDOWSCURSORSGlobe.ani")
jiu = SetClassLong(hwnd, -12, xin)
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
SetClassLong hwnd, -12, jiu
End Sub


"让VB使用彩色及动画光标的方法"由第二电脑网原创提供,转载请注明:http://www.002pc.com/master/College/Language/VB/12477.html


关键字:

关于《让VB使用彩色及动画光标的方法》文章的评论

站内搜索: 高级搜索

热门搜索: Windows style 系统 tr IP QQ CPU 安装 function 注册 if td