sp; mhAniCursor = LoadCursorFromFile("c:\win95\cursors\appstart.ani")
lResult = SetClassLong((Me.hwnd), GCL_HCURSOR, mhAniCursor)
lResult = GetWindowRect((Me.hwnd), RT_FormArea)
lResult = ClipCursor(RT_FormArea)
End Sub
将如下的代码添加到Command2的单击事件中:
Private Sub Command2_Click()
Dim lResult As Long
Dim RT_ScreenArea As RECT
RT_ScreenArea.Top = 0
RT_ScreenArea.Left = 0
RT_ScreenArea.Bottom = Screen.Height \ Screen.TwipsPerPixelX
RT_ScreenArea.Right = Screen.Width \ Screen.TwipsPerPixelY
lResult = ClipCursor(RT_ScreenArea)
lResult = SetClassLong((Me.hwnd), GCL_HCURSOR, mhBaseCursor)
lResult = DestroyCursor(mhAniCursor)
End Sub
----通过按下F5键来运行该程序,单击“显示动画光标”命令按钮,则在窗体的范围内光标变成为APPSTART.ANI光标,并且光标被限制在窗体的范围内。单击“恢复缺省光标”命令按钮,则窗体中的光标被恢复为缺省的光标。注意,在退出该样例
程序之前,需要单击“恢复缺省光标”命令按钮,否则将不能在系统中正确进行其它操作。