How to register a window with the default cursor using LoadImage() instead of LoadCursor?

I can register a window class with the default cursor using:

WNDCLASSEX wc = {0}; wc.hCursor = LoadCursor(nullptr, IDC_ARROW); 

But after looking at the docs for LoadCursor here:

it says that "This function has been superseded by the LoadImage function"

What is the equivalent LoadCursor call to get the default arrow cursor?

1

1 Answer

According to the document:

hInst

To load an OEM image, set this parameter to NULL.

name

To pass these constants to the LoadImage function, use the MAKEINTRESOURCE macro. For example, to load the OCR_NORMAL cursor, pass MAKEINTRESOURCE(OCR_NORMAL) as the lpszName parameter, NULL as the hinst parameter, and LR_SHARED as one of the flags to the fuLoad parameter.

so just use the following code:

wndclass.hCursor = (HCURSOR) LoadImage(NULL, MAKEINTRESOURCE(OCR_NORMAL), IMAGE_CURSOR, 0, 0, LR_SHARED); 
1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like