I want to capture as a bitmap the system cursor on Windows OSes as accurately as possible. The provided API for this is to my knowledge GetCursorInfo, DrawIconEx.
The simple chain of actions is:
- Get cursor by using GetCursorInfo
- Paint the cursor in a memory DC by using DrawIconEx.
Here is how the code looks roughly.
CURSORINFO CursorInfo;
(VOID)memset(&CursorInfo, 0, sizeof(CursorInfo));
CursorInfo.cbSize = sizeof(CursorInfo);
if (GetCursorInfo(&CursorInfo) &&
CursorInfo.hCursor)
{
// ... create here the memory DC, memory bitmap
boError |= !DrawIconEx(hCursorDC, // device context
0, // xLeft
0, // yTop
CursorInfo.hCursor, // cursor handle
0, // width, use system default
0, // height, use system default
0, // step of animated cursor !!!!!!!!!
NULL, // flicker free brush, don't use it now
DI_MASK | DI_DEFAULTSIZE); // flags
// ... do whatever we want with the cursor in our memory DC
}
Now, anyone knows how I could get which step of the animated cursor is being drawn (I need the value that can be then passed to the istepIfAniCur parameter of DrawIconEx...)? Currently the above code obviously always renders only the first step of an animated cursor.
I suspect this can not be easily done, but it's worth asking anyway.