开发者

GetObject fails on a text cursor

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, 开发者_StackOverflow社区clue, would be much appreciated !! Thanks a lot in advance !


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 is probably NULL. MSDN says for ICONINFO.hbmColor:

A handle to the icon color bitmap. This member can be optional if this structure defines a black and white icon.

Usually, the text cursor (IDC_IBEAM) is defined by using only color inversion and transparency, explaining the fact that hbmColor is NULL. You should always apply hbmMask to the optional hbmColor.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜