GetObject 在文本光标上失败
我正在尝试获取光标位图以便使用鼠标光标计算快照。
它与标准光标(即箭头)一起工作正常,但一旦光标变成文本光标,它就会失败。 基本上我正在这样做:
//Fetching the cursor handle
GetCursorInfo( &m_infos );
m_handle = m.infos.hCursor;
//Fetching cursor info
ICONINFO infos;
HICON icon = CopyCursor( m_handle );
GetIconInfo( icon, &infos );
BITMAP bitInfos;
if ( GetObject( infos.hbmColor, sizeof( bitInfos ), &bitInfos ) == 0 )
{
qDebug() << "Error N:" << GetLastError();
}
问题是,GetObject() 和 GetLastError() 返回 0...所以我无法知道哪个是错误...
我在 Win7 上运行此代码,使用 QtCreator 和明文.
任何想法,线索,将不胜感激! 预先非常感谢!
I'm trying to fetch the cursor bitmap in order to compute a snapshot with the mouse cursor.
It works fine with the standard cursor (IE. the arrow) but it fails as soon as the cursor becomes a text cursor.
Basically I'm doing this :
//Fetching the cursor handle
GetCursorInfo( &m_infos );
m_handle = m.infos.hCursor;
//Fetching cursor info
ICONINFO infos;
HICON icon = CopyCursor( m_handle );
GetIconInfo( icon, &infos );
BITMAP bitInfos;
if ( GetObject( infos.hbmColor, sizeof( bitInfos ), &bitInfos ) == 0 )
{
qDebug() << "Error N:" << GetLastError();
}
The problem is, GetObject() AND GetLastError() return 0... so i'm not abble to know which is the error...
I'm running this code on Win7, using QtCreator and MingW.
Any idea, clue, would be much appreciated !!
Thanks a lot in advance !
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
没有“文本光标”。它称为插入符号,其处理方式与鼠标指针完全不同。有关详细信息,请参阅 MSDN 上的使用插入符。
There is no "text cursor". It's called a caret, and it's dealt with totally differently than the mouse pointer. See Using Carets on MSDN for more info.
infos.hbmColor
可能是NULL
。 MSDN 对于ICONINFO.hbmColor
的说法:通常,文本光标(IDC_IBEAM)仅使用颜色反转和透明度来定义,这解释了
hbmColor
为NULL
这一事实。您应该始终将hbmMask
应用于可选的hbmColor
。infos.hbmColor
is probablyNULL
. MSDN says forICONINFO.hbmColor
:Usually, the text cursor (IDC_IBEAM) is defined by using only color inversion and transparency, explaining the fact that
hbmColor
isNULL
. You should always applyhbmMask
to the optionalhbmColor
.