Why does the DrawIcon function draw at the default icon size?

Raymond Chen

Miral wondered why the Draw­Icon function draws at the default icon size instead of respecting the actual icon size. After all, if you loaded a nonstandard-sized icon via Load­Image, 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 Draw­Icon function was written, the Load­Image function didn’t exist, and wouldn’t exist for over a decade. The Load­Image 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 Load­Icon 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 Draw­Icon 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. Therefore, Draw­Icon always draws at the standard icon size. Think of it as Draw­Icon­Back­Compat. If you are a fancy new application that can handle icons at nonstandard sizes, then use Draw­Icon­Ex and don’t pass the DI_DEFAULT­SIZE flag. 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 Draw­Icon function itself passed that flag (and still does today, even though it no longer does anything).