我想在Windows中获取光标图标。 我觉得语言我用的是不是在这里非常重要,所以我只写与WinAPI的功能,我想用伪代码:WinAPI获取鼠标光标图标
c = CURSORINFO.new(20, 1, 1, POINT.new(1,1));
GetCursorInfo(c); #provides correctly filled structure with hCursor
DrawIcon(GetWindowDC(GetForegroundWindow()), 1, 1, c.hCursor);
所以这部分工作得很好,它吸引光标当前活动窗口。 但这不是我想要的。我想获得一组像素,所以我应该在内存中绘制它。
我试图做这样的:
hdc = CreateCompatibleDC(GetDC(0)); #returns non-zero int
canvas = CreateCompatibleBitmap(hdc, 256, 256); #returns non-zero int too
c = CURSORINFO.new(20, 1, 1, POINT.new(1,1));
GetCursorInfo(c);
DrawIcon(hdc, 1, 1, c.hCursor); #returns 1
GetPixel(hdc, 1, 1); #returns -1
为什么不GetPixel()返回COLORREF?我错过了什么?
我对WinAPI不太了解,所以我可能会犯一些愚蠢的错误。