Date: | July 18, 2005 / year-entry #192 |
Tags: | history |
Orig Link: | https://blogs.msdn.microsoft.com/oldnewthing/20050718-16/?p=34913 |
Comments: | 13 |
Summary: | One of the problems beginners run into when they start using shell common controls is that they forget to call the InitCommonControls function. But if you were to disassemble the InitCommonControls function itself, you'll see that it, like the FlushInstructionCache function, doesn't actually do anything. Then why do you need to call it? As with... |
One of the problems beginners run into when they start using shell common controls is that they forget to call the Then why do you need to call it? As with Recall that merely listing a lib file in your dependencies doesn't actually cause your program to be bound to the corresponding DLL. You have to call a function in that DLL in order for there to be an import entry for that DLL. And Without the That's why you have to call a function that does nothing. It's for your own good. (Of course, there's the new |
Comments (13)
Comments are closed. |
If I understand correctly, then this implies that even if I have the call to InitCommonControls in a code block that is never executed (but not optimised away by the compiler) or if I use the common controls before calling ICC (by, say, putting it at the end of WinMain), it should still work?
… until it doesn’t.
"Only the classic Windows 95 classes are registered when COMCTL32.DLL loads."
Why isn’t this fact documented?
Because you shouldn’t be relying on it. Just call InitCommonControlsEx like the documentation says.
So when are the Win95 classes registered? In DllMain?
That would mean that the standard classes are always registered, and the non-Win95 ones get registered only when ICCEx() is called. And that comctl32.dll broke the DllMain rules.
Steven, experiment seems to show that you’re correct. Interesting!
Thanks Seth. That explains why I had some trouble creating window classes with names colliding with the COMCTL32.DLL ones even when I didn’t actually call ICC. The only way around that was skip to using LoadLibrary.
For quest:
InitCommonControls doc:
"This function is obsolete. New applications should use the InitCommonControlsEx function."
InitCommonControlsEx doc:
"Registers specific common control classes from the common control dynamic-link library (DLL)."
————-
Is logical. At the time when InitCommonControls was created and documented, it did load all available (at that time) control window classes.
But if you read the documentation of InitCommonControls, you know is obsolete and you should not use it.
According to Mike Dimmick (http://mikedimmick.blogspot.com/2004/07/changes-to-win32-api-in-longhorn_11.html) there’s a Histogram control coming in Longhorn’s common controls. (Like the Task Manager CPU usage I’d assume?)
I hope that this ends up being true–Despite Microsoft’s shifting emphasis to WinFX/Avalon, there is still a good use for classic Win32 controls provided by the OS.
Hmmm, but in my opinion if someone who does not know this and reads the documentation for InitCommonControls:
"Registers and initializes the common control window classes."
One would normally think that it registers *all* available common control window classes.
Why was "Ex" chosen as the extension for a new version of a function call? Why not "2nd" or "_2"? What happens when there’s a third version? "ExEx"? I presume there’s some bit of interesting history here that *someone* must know.
Yeah but, there is only written that you *should* use the InitCommonControlsEx function. But there is no word that this is a *must* for window classes other than the Windows 95 classes.
I think there is missing a sentence about it in the documentation, but don’t lets discuss too much on it. ;-)
Ryan: No need for an InitCommonControlsExEx, the INITCOMMONCONTROLSEX structure has a size field, that means Microsoft can extend the structure if the functions needs more parameters.
Because one day, it may very well end up doing something?
PingBack from http://zeromemory.wordpress.com/2008/04/08/when-a-messagebox-in-initinstance-didnt-show/