Microsoft Developer Network >
Página Inicial dos Fóruns
>
Visual C++ General
>
Low cursor quality in high DPI
Low cursor quality in high DPI
My need is to get the current system cursor and draw it on a device context (DC). Operating system is Vista and Windows 7.
To do this I am using GetCursorInfo API. I retrieve the cursor handle from CURSORINFO structure and then pass it to DrawIcon API to paint the cursor on DC.
This works perfectly when system is set to normal DPI. The cursor quality is good and cursor size is exactly same as the system cursor.
But when when DPI is changed to some high value, the cursor which is drawn is of low quality and also bigger in size than the system cursor.
How to get the exact same cursor as the current system cursor even in High DPI? I even tried loading a custom cursor but even it has the same issue.
Is there any other method to do this?
ThanksHCURSOR hcur; CURSORINFO cursorinfo; cursorinfo.cbSize = sizeof(CURSORINFO); if(GetCursorInfo(&cursorinfo)) { hcur = cursorinfo.hCursor; // Draw cursor on screen HDC hdc = ::GetDC(NULL); ::DrawIcon(hdc, 100, 100, hcur); DeleteDC(hdc); }
Thanks, Amol Patki
Respostas
- Thanks Nikita,
Your reply was indeed helpful. I have voted it helpful.
I tried with with DI_DEFAULLTSIZE but did not work.
But DrawIconEx is the solution. I am positing the modified code here. (Note that DI_DEFAULLTSIZE is not used because using this flag gave same result as DrawIcon API)
HCURSOR hcur; CURSORINFO cursorinfo; cursorinfo.cbSize = sizeof(CURSORINFO); if(GetCursorInfo(&cursorinfo)) { hcur = cursorinfo.hCursor; BITMAP bitmap; GetObject(iconinfo.hbmColor, sizeof(BITMAP), &bitmap); // Draw cursor on screen HDC hdc = ::GetDC(NULL); ::DrawIconEx(m_hMemDC, 100, 100, hcur, bitmap.bmWidth, bitmap.bmHeight, 0, NULL, DI_NORMAL); DeleteDC(hdc); }
Thanks, Amol Patki- Marcado como RespostaAmol P segunda-feira, 9 de novembro de 2009 5:59
Todas as Respostas
- Try DrawIconEx with DI_DEFAULTSIZE flag.
- Thanks Nikita,
Your reply was indeed helpful. I have voted it helpful.
I tried with with DI_DEFAULLTSIZE but did not work.
But DrawIconEx is the solution. I am positing the modified code here. (Note that DI_DEFAULLTSIZE is not used because using this flag gave same result as DrawIcon API)
HCURSOR hcur; CURSORINFO cursorinfo; cursorinfo.cbSize = sizeof(CURSORINFO); if(GetCursorInfo(&cursorinfo)) { hcur = cursorinfo.hCursor; BITMAP bitmap; GetObject(iconinfo.hbmColor, sizeof(BITMAP), &bitmap); // Draw cursor on screen HDC hdc = ::GetDC(NULL); ::DrawIconEx(m_hMemDC, 100, 100, hcur, bitmap.bmWidth, bitmap.bmHeight, 0, NULL, DI_NORMAL); DeleteDC(hdc); }
Thanks, Amol Patki- Marcado como RespostaAmol P segunda-feira, 9 de novembro de 2009 5:59

