我想尽可能准确地捕获Windows操作系统上的系统光标作为位图。 据我所知,提供的API是GetCursorInfo,DrawIconEx。
简单的行动链是:
使用GetCursorInfo获取游标 使用DrawIconEx将光标绘制在内存DC中。以下是代码的粗略表示。
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 }现在,任何人都知道如何绘制动画光标的哪一步(我需要将值传递给DrawIconEx的istepIfAniCur参数...)? 目前,上面的代码显然总是只渲染动画光标的第一步。
我怀疑这不容易做到,但无论如何都值得问。
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.
最满意答案
不幸的是,我不认为有一个Windows API公开了光标动画的当前帧。 我假设你正在追求的是:你制作快照的瞬间光标的外观。
Unfortunately, I don't think there's a Windows API that discloses the current frame of the cursor animation. I assume that's what you're after: the look of the cursor at the instant you make the snapshot.
更多推荐
发布评论