我找到了一种解决方法 - 传递给UINT的DrawIconEx函数最大值的 istepIfAniCur 参数。不可能有人会创建具有 4,294,967,295 帧的动画光标(可能对于某些光标电影 :)
有了这个事实,您可以将此值传递给DrawIconEx函数,如果光标处于动画状态(因为超出帧范围),该函数将返回 False,在静态光标的情况下返回 True,因为它忽略了 istepIfAniCur 参数。您应该将 0 传递给 diFlags 参数,因为不需要绘制任何内容。
这是德尔福的例子:
if not DrawIconEx(Canvas.Handle, 0, 0, hCursor, 0, 0, High(Cardinal), 0, 0) then
Caption := 'Cursor is animated ...'
else
Caption := 'Cursor is not animated ...';
因为我答应了 C++ 标签,所以这是我的翻译尝试
if (!DrawIconEx(this->Canvas->Handle, 0, 0, hCursor, 0, 0, UINT_MAX, NULL, 0))
this->Caption = "Cursor is animated ...";
else
this->Caption = "Cursor is not animated ...";
当DrawIconEx失败时,您可以使用GetLastError函数检查操作系统错误ERROR_INVALID_PARAMETER
也指示超出帧范围。