Reset custom system cursor to normal
.net, c#, visual-c++, windows
Solution
As documented, the SetSystemCursor() function already destroys the passed cursor so destroying it again isn't going to have any effect.
You'll need to store a copy of the old cursor so you can restore it later:
// Global Variables:
HCURSOR hOldCursor;
...
hOldCursor = CopyCursor(LoadCursor(NULL, MAKEINTRESOURCE(IDC_ARROW)));
HCURSOR hNewCursor = CopyCursor(LoadCursor(hInstance, MAKEINTRESOURCE(IDC_MYCURSOR)));
SetSystemCursor(hNewCursor, OCR_NORMAL);
And restore it like this:
SetSystemCursor(hOldCursor, OCR_NORMAL);
DestroyCursor(hOldCursor);
hOldCursor = NULL;
Note the considerable pain you cause when your program terminates without restoring the cursor. As experienced by me testing this code. Changing system cursors is quite unfriendly since it has a global effect on all other programs that run on the desktop.
Problem
i change the system cursor with SetSystemCursor but when i try to reset the system cursor to nornal with DestroyCursor nothing happens !! Any ideas ? Thanks !