我使用此代码在屏幕上获取鼠标位置并且它正在工作。我也得到光标的宽度和高度。我需要的是在调用函数 GetIconInfo 时的光标图标。在 ii iI 中有 ii.hbmColor 和 ii.hbmMask。hbmColor 的值为 0x0,hbmMask 的值为 0x2f0517f1。我可以从那两个指针中提取鼠标光标吗?如何提取?
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);
}
}
}
Run Code Online (Sandbox Code Playgroud) 我在c中有列表指针:
list<int> * pointer = (list<int> *)malloc(sizeof(list<int>));
Run Code Online (Sandbox Code Playgroud)
当我尝试:
pointer->push_back(1);
Run Code Online (Sandbox Code Playgroud)
我得到错误,因为malloc不调用列表构造函数.我知道用c ++执行此操作:
list<int> * pointer = new list<int>();
Run Code Online (Sandbox Code Playgroud)
但我需要这个在c?
有人知道解决方案吗?