Animation cursor using Win95

zhaozj2021-02-11  194

- In Windows 95 system, there is a feature that is not available in Windows 3.x - supports animated cursor files. You can see the cursor files of these animations in the CURSORS subdirectory in the Windows 95 directory, all of which have extensions * .ani. Using the appropriate animation cursor in the program to greatly improve the appearance of the program, this article describes how to use the animation cursor file included with Windows 95 in your Visual Basic application.

Use animation cursor file

---- To use the animation cursor with Windows 95 in Visual Basic, you need to use the following Windows Application Programming Interface (API) function:

LoadCursorformFile, used to load the cursor file from the disk; CLIPECURSOR is used to limit the cursor within a fixed rectangular area; getWindowRect, used to get the rectangular area, in the sample program, the program main form SetClasslong, for setting up and extracts the data of the window class, so that the cursor is displayed on the form; getClasslong function, before exiting the application, you need to set the default cursor of the application to execute the previous cursor, so you need When the program is run, the previous cursor state is backed up, this work is done by this function; DestroyCursor, after the cursor is correctly displayed, you need to use this function to cancel the loaded cursor.

Sample program

---- The sample program below will display the AppStart.ani animation cursor file under the C: / Win95 / Cursors directory in the form area. If your Windows 95 is different, you need to modify the sample program to be correct Show the movie cursor.

Start a new project in Visual Basic, build FORM1 with the default method. Create a command button control on Form1, and use the default method to establish Command1. Set its CAPTION property to "Display Animation Cursor". Create a second command button control on Form1, and use the default method to create Command2. Set its CAPTION property to "Restore the Default Cursor". Create a new module, build Module1.bas with the default approach. The following statement types and constants common declaration statements to the portion Module1.Bas: Option ExplicitType RECT Left As Long Top As Long Right As Long Bottom As LongEnd TypePublic Const GCL_HCURSOR = (-12) Declare Function ClipCursor Lib "user32" (lpRect As Any) As LongDeclare Function DestroyCursor Lib "user32" (ByVal hCursor As Long) As LongDeclare Function LoadCursorFromFile Lib "user32" Alias ​​"LoadCursorFromFileA" (ByVal lpFileName As String) As LongDeclare Function GetWindowRect Lib "user32" (ByVal hwnd As Long , lpRect As RECT) As LongDeclare Function SetClassLong Lib "user32" Alias ​​"SetClassLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As LongDeclare Function GetClassLong Lib "user32" Alias ​​"GetClassLongA" (ByVal hwnd As Long BYVAL NINDEX AS Long) As long Note The above declaration statement needs to be written in one line.

转载请注明原文地址:https://www.9cbs.com/read-4056.html

New Post(0)