How to get VS C ++ mouse cursor icon

I use this code to get the mouse position on the screen and it works. I also get the width and height of the cursor. I need a cursor icon at the time the GetIconInfo function is called. In ii iI there are ii.hbmColor and ii.hbmMask. The value of hbmColor is 0x0, hbmMask is 0x2f0517f1. Can I extract the mouse cursor from these two pointers and how?

  CURSORINFO cursorInfo = { 0 };
  cursorInfo.cbSize = sizeof(cursorInfo);

  HDC memoryDC = (HDC)malloc(100);
  memset(memoryDC, 0x00, 100);

  if (::GetCursorInfo(&cursorInfo))  {
    ICONINFO ii = {0};
    GetIconInfo(cursorInfo.hCursor, &ii);

    BITMAP bm;
    GetObject(ii.hbmMask,sizeof(BITMAP),&bm);

    DeleteObject(ii.hbmColor);
    DeleteObject(ii.hbmMask);
    ::DrawIcon(memoryDC, cursorInfo.ptScreenPos.x - ii.xHotspot, cursorInfo.ptScreenPos.y - ii.yHotspot, cursorInfo.hCursor);


    for(int i = 0; i < bm.bmWidth; i++){
        for(int j = 0; j < bm.bmHeight; j++){
            COLORREF c = GetPixel(memoryDC, i, j);
            printf("%x", c);

        }
    }
  }
+3
source share
2 answers
  CURSORINFO cursorInfo = { 0 };
  cursorInfo.cbSize = sizeof(cursorInfo);

  if (::GetCursorInfo(&cursorInfo))
  {
    ICONINFO ii = {0};
    GetIconInfo(cursorInfo.hCursor, &ii);
    DeleteObject(ii.hbmColor);
    DeleteObject(ii.hbmMask);
    ::DrawIcon(memoryDC, cursorPos.x - ii.xHotspot, cursorPos.y - ii.yHotspot, cursorInfo.hCursor);
  }
+2
source

cursor information is formatted as described here: http://www.daubnet.com/en/file-format-cur

, , 1 = 8 . , , ( 8), 26x23 . 26 4 , 3 , 24 , 2 4- , 2 , 6 , .

-1

Source: https://habr.com/ru/post/1760248/


All Articles