Cursor style not updated

I have a regular Windows GUI application (made using the API, not MFC), and when I move the mouse and turn off the application, and the mouse changes styles (for example, when you move it along the border, it changes to the size of the arrow, etc.) etc.), but sometimes it “sticks” in this style, so that I can move the mouse and it will remain in the resize arrow or something else, even after it from the window border. It corrects itself if I move it around another control.

This is just an inconvenience, but it looks unprofessional, and I would like to fix it. How can I do this where it is constantly updated?

+3
source share
3 answers

Set the correct cursor handle when registering a window class. See WNDCLASSEX::hCursor. Use LoadCursorto load a valid cursor. How,

WNDCLASSEX wc = {0};
...
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
...
RegisterClassEx(&wc);
+7
source

The answer to ten questions is correct. Here is a bit more background.

When the mouse moves inside the window and is not captured, the window receives a message WM_SETCURSOR. The name of the message may be a bit confusing. This is basically a window for setting the cursor, not instructions for setting the cursor.

A window can process this message by calling SetCursorand returning.

punt, DefWindowProc, . - hCursor WNDCLASS . .

( , DefWindowProc .)

- , , - , WM_SETCURSOR, SetCursor , TRUE.

. SetCursor.

+4

Source: https://habr.com/ru/post/1781521/


All Articles