捕捉动画系统光标在Windows上显示的步骤
Capture which step of an animated system cursor is being shown on Windows
我想尽可能准确地将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参数的值…)?目前,上面的代码显然总是只呈现动画光标的第一步。
我怀疑这不是一件容易的事,但无论如何都值得一问。
遗憾的是,我认为没有Windows API公开光标动画的当前帧。我想这就是你想要的:在你制作快照的那一刻光标的外观。
我怀疑您遗漏了一个步骤。
你需要创建一个位图来选择你的设备上下文,否则你的位图只是一个像素。
请参阅MSDN文档中的CreateCompatibleBitmap:
HBITMAP创建兼容位图(HDC HDC,//DC句柄int nWidth,//位图的宽度,以像素为单位int nHeight//位图的高度,以像素为单位);
使用DrawIconEx,UINT istepIfAniCur参数允许您选择要绘制的帧(如果它是动画光标)。
它在你的评论中说:
0,//动画光标的步长
相关文章:
- 如何使 windows 命令提示符在C++可执行文件上显示返回值?
- std::strftime 在 Windows 中使用 GMTIME 将时区 UTC 显示为 UTC+1
- Android NDK clang 编译器错误在 Windows 上显示'No such file or directory'
- 如何在"SUBSYSTEM:WINDOWS"下显示并输出到Windows(C++ WinApi)上的
- Windows 资源管理器中的图标在使用 resource.rc 时显示 2 个不同的图标
- C++程序工作,但 Windows 显示"程序.exe已停止工作"
- 使用 C++ 显示 C:\Windows\System32\config 的内容
- Windows API SIZE_T在内存和控制台中不显示相同的值
- 显示和隐藏Windows 10屏幕键盘(osk.exe)时遇到问题
- c ++ 是否有任何用于列出 Windows 驱动程序管理器控制台中显示的设备驱动程序的 Windows API?
- 在C Windows程序中显示文本文件内容
- 在任何 Windows 版本上全屏显示控制台
- 如何在C++的程序中显示Windows的"DLL not found"错误?
- ROS2 COLCON构建未在Windows中显示任何错误消息
- QSSLCertificatifific如何获取Windows中显示的公共密钥
- Unicode 输出未显示在 Windows 控制台中
- 标准输出输出不会显示在基于 Windows MFC 对话框的应用的控制台上
- 使QT/C 程序显示其文件类型,如Windows上已知
- 如何显示 Windows 资源管理器上下文(右键单击)菜单
- 在Qt应用程序中打开并显示windows命令提示符