First, import the. ani file to the project.
Click the Insert-> Resource menu in VC, click the Import button in the pop-up Insert Resource dialog box, and select "all files * in the" file type "drop-down list in the pop-up open file dialog box *. * ", select. ani File
Click the Import button. A Custom Resource dialog box is displayed. In the Resource type edit box, enter the name of the Resource to be created, for example, anicursor. Then, click OK, in this way, a resource named IDR_ANICURSOR1 will appear in your resource editor! In this way, the. ani file is imported into your program as a resource!
The dialog box is used as an example to describe how to use this resource.
1. First define a handle in the header file of the dialog box.
HCURSOR hCursor;
2. Load the resource in OnInitDialog, the initialization function of the dialog box. The Code is as follows:
HCursor = LoadCursor (AfxGetInstanceHandle (), MAKEINTRESOURCE (IDR_ANICURSOR1 ));
3. Reload the WM_SETCURSOR message in the dialog box and add the following code to the Message response function:
SetCursor (hCursor );
Return TRUE;
// Note that the default return statement after the message response function is added is
// Return CDialog: OnSetCursor (pWnd, nHitTest, message );
// We only need to let this function return true.