Some time ago I had a problem with icon drawing.
When I tried to draw an icon with DrawIcon
it ended up being drawn at the wrong size.
A call to
GetIconInfo
confirmed that the icon was
48×48, but it drew at 32×32.
The answer is documented in a backwards sort of way
in the DrawIconEx
function, which says at the bottom,
To duplicate DrawIcon (hDC, X, Y, hIcon), call DrawIconEx as follows:
DrawIconEx (hDC, X, Y, hIcon, 0, 0, 0, NULL, DI_NORMAL | DI_COMPAT | DI_DEFAULTSIZE);
Aha, if you use DrawIcon
, then the icon size is ignored
and it is drawn with DI_DEFAULTSIZE
.
The fix, therefore, was to switch to the DrawIconEx
function so I could remove the DI_DEFAULTSIZE
flag,
thereby permitting the icon to be drawn at its actual size.
- DrawIcon(hdc, pt.x, pt.y, hico); + DrawIconEx(hdc, pt.x, pt.y, hico, 0, 0, 0, NULL, DI_NORMAL | DI_COMPAT);
A bonus quirk of the
DI_DEFAULTSIZE
flag
(and therefore of the
DrawIcon
function)
is that the drawing is done at the default icon size,
even if you asked it to draw a cursor.
0 comments