6.2.2 Explicitly Setting a Cursor Shape

Your application does not have to specify a class cursor. Instead, you can set the hCursor field to NULL to indicate that the window class has no class cursor. If a window has no class cursor, Windows will not automatically change the shape of the cursor when it moves into the client area of the window. This means that your application will need to display the cursor itself.

To use any cursor, whether built-in or custom, your application must load it first. For example, to load the custom cursor MyCursor (defined in your application's resource-definition file) add the following statements to your initialization function:

static HCURSOR hMyCursor; /* static variable */
hMyCursor = LoadCursor(hinst, "MyCursor");

Then, to change the cursor shape, use the SetCursor function to set the shape each time the cursor moves into the client area. Since Windows sends a WM_MOUSEMOVE message to the window for each cursor movement, you can manage the cursor by adding the following statements to the window procedure:

case WM_MOUSEMOVE:
    SetCursor(hMyCursor);
    break;

Note:

If you want your application to display the cursor itself, you must set the class-cursor member to NULL. Otherwise, Windows will attempt to set the cursor shape for each WM_MOUSEMOVE message, even though your application is also setting the cursor shape. This will result in a noticeable flicker as the cursor is moved through the window.