Why does the DrawIcon function draw at the default icon size?
Miral wondered why the
DrawIcon function draws at the default icon size instead of respecting the actual icon size. After all, if you loaded a nonstandard-sized icon via
LoadImage, then presumably you want to use that nonstandard size.
The question is one of those types of questions that fails to understand history, like asking why NASA didn’t send the space shuttle to rescue the Apollo 13 astronauts.
At the time the
DrawIcon function was written, the
LoadImage function didn’t exist, and wouldn’t exist for over a decade. The
LoadImage function showed up in Windows 95, but Windows was drawing icons long before then, and for a long time, the only way to load icons was with the
LoadIcon function, which always loaded icons at their default size. When the ability to create nonstandard-sized icons was added, you then had the question of how to draw them. Code which relied on the fact that all icons were the same size would call
DrawIcon expecting the result to be a 32×32 image (or whatever your icon size was). If you drew it at its actual size, you would either have this L-shaped “hole” in the application (if the actual size was smaller), or you would have an icon that overflowed some other part of the application. Either way you lose.
DrawIcon always draws at the standard icon size. Think of it as
DrawIconBackCompat. If you are a fancy new application that can handle icons at nonstandard sizes, then use
DrawIconEx and don’t pass the
Bonus chatter: The documentation states that the
DI_COMPAT has no effect. Presumably it had an effect in some previous version of Windows?
In Windows 95, if you used the
LoadCursor to load a standard cursor (like, say,
IDC_ARROW), but the standard arrow cursor was customized by the user, Windows would draw the customized cursor. Passing the
DI_COMPAT flag forced the standard arrow cursor to be drawn.
So far as I can tell, nobody ever passed that flag.
Update: My claim that nobody passed that flag is incorrect. The
DrawIcon function itself passed that flag (and still does today, even though it no longer does anything).