Capturing which step of an animated system cursor is displayed in Windows

I want to fix the system cursor on Windows as accurately as possible. The API provided for this, to my knowledge, is GetCursorInfo, DrawIconEx.

Simple chain of actions:

  • Get cursor using GetCursorInfo
  • Draw a cursor in DC memory using DrawIconEx.

Here's what the code looks like.

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 does anyone know how I can get which step of the animation cursor is drawn (I need a value that can then be passed to the istepIfAniCur DrawIconEx ... parameter)? Currently, the above code, obviously, always displays only the first step of the animated cursor.

I suspect this is not easy to do, but still worth asking.

+3
source share
2

, , Windows API, . , : .

+2

, .

, .

. CreateCompatibleBitmap MSDN:

HBITMAP CreateCompatibleBitmap(
  HDC hdc,        // handle to DC
  int nWidth,     // width of bitmap, in pixels
  int nHeight     // height of bitmap, in pixels
);

DrawIconEx UINT istepIfAniCur , , .

:

0,  // step of animated cursor 
0
source

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


All Articles