VB本身不支持彩色光标和动画光标,但可以通过调用Windows的API函数实现这一目的。这里用到两个API函数,LoadCursorFromFile用于装入新光标(xin),需要指明新光标的具体路径及文件名;SetClassLong用于设置使用新光标(xin)。这一函数使用时会返回一个代表前一个光标的变量值(jiu),为我们关闭程序时得以方便的恢复原始光标(jiu)
PrivateDeclareFunctionLoadCursorFromFileLib”user32″Alias”LoadCursorFromFileA”(ByVallpFileNameAsString)AsLong
PrivateDeclareFunctionSetClassLongLib”user32″Alias”SetClassLongA”(ByValhwndAsLong,ByValnIndexAsLong,ByValdwNewLongAsLong)AsLong
DimxinAsLong
DimjiuAsLong
PrivateSubForm_Load()
xin=LoadCursorFromFile(“C:\WINDOWS\CURSORS\Globe.ani”)
jiu=SetClassLong(hwnd,-12,xin)
EndSub
PrivateSubForm_QueryUnload(CancelAsInteger,UnloadModeAsInteger)
SetClassLonghwnd,-12,jiu
EndSub->