我想在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不太瞭解,所以我可能會犯一些愚蠢的錯誤。