Helpful Information
 
 
Category: C Programming
LoadCursor and replace original again

Hi,

I need to change the cursor of my application globally (its a recorder).

Here is the code to change it



HCURSOR hCurs;

hCurs = CopyCursor(LoadCursor(g_hInstance, MAKEINTRESOURCE(IDC_RECPOINTER))); // Change the cursor
SetSystemCursor(hCurs, (DWORD)IDC_ARROW);


Now how can I reset the original mouse cursor when I exit this dialog?

Ive tried hanging onto a ref to hCurs in another var and then loading that but no joy.

Can any1 help?

Use SetCursor instead of CopyCursor. SetCursor returns the handle of the old cursor when you call it. Then you can use that old handle to restore the cursor when you're done.

SetCursor does return the handle of the previous cursor, but unfortunately it cannot be used 'globally'. If you need to change the global cursor, then you are left with no option but to use SetSystemCursor()

Hi, there.

You can use GetCursorInfo() function to return the system cursor properties(HCURSOR and more), so you can restore it when your done.

Hope this helps... :)

Hi, there.

You can use GetCursorInfo() function to return the system cursor properties(HCURSOR and more), so you can restore it when your done.

Hope this helps... :)

hmm....are you sure this can help us restore the cursor?
The CURSORINFO structure that this function points to does not provide any details about the cursor image. Just screen position,co-ordinates,size etc. won't help us to get back the actual cursor.
Basically you may need to use the other function - GetIconInfo(), b'coz the ICONINFO structure contains essential details like Mask and Color of the cursor. But the other limitation of using this is that it can't restore animated cursors.










privacy (GDPR)