Cursor Icon hbmColor und hbmMask
-
Hallo Leute,
unter WinXP/Windows7 will ich das Bitmuster des Cursor Icons darstellen.
Die gesetzten Pixel werden mit X, nicht gesetzte mit space dargestellt.Leider funktioniert's nicht ganz: ich bekomme nur einen Teil der Pixel,
es fehlen offenbar die Informationen die in ICONINFO.hbmColor und ICONINFO.hbmMask
enthalten sind. (Siehe Code)Wie komme ich an diese Informationen, sodaß ich den Cursor vollständig
darstellen kann?Danke fürs Lesen und Tipps
Wolf#include <windows.h> #include <winuser.h> #include <wingdi.h> #include <stdio.h> void getCURInfo(); int main() { getCURInfo(); system("pause"); return 0; } void getCURInfo() { int x, y, c; int w = GetSystemMetrics(SM_CXICON); int h = GetSystemMetrics(SM_CYICON); HWND hWnd = GetDesktopWindow(); HDC hDDC = GetDC(hWnd); HDC hCDC = CreateCompatibleDC(0); HBITMAP hBMP = CreateCompatibleBitmap(hDDC, w, h); SelectObject(hCDC, hBMP); for (x=10; x > 0; x--) { printf("%d ", x); Sleep(1000); } printf("\nwidth=%d height=%d\n", w, h); CURSORINFO aCursor; aCursor.cbSize = sizeof(CURSORINFO); GetCursorInfo(&aCursor); if (aCursor.flags) { HICON hIcon = CopyIcon(aCursor.hCursor); ICONINFO aIcon; GetIconInfo(hIcon, &aIcon); DrawIcon(hCDC, 0, 0, hIcon); for (y=0; y < h; y++) { for (x=0; x < w; x++) { c = (int)GetPixel(hCDC, x, y); if (c) printf("X"); else printf(" "); } printf("\n"); } DestroyIcon(hIcon); } else { printf("no cursor\n"); } ReleaseDC(hWnd, hDDC); DeleteDC(hCDC); return; }