I was about to write a tutorial on how to create a custom Win32 control in C when I found that someone had beat me to it: Creating Custom Controls From Scratch. Overall it is quite good, and I learned a few new things myself. (By the way, the entire Catch22 Tutorials site is filled with fascinating material for Win32 developers.)
One thing to note: If you separate your custom control into a DLL, you will need to create an initialization function which registers the window classes (similar to InitCommonControls()). Be sure to pass the CS_GLOBALCLASS flag to RegisterClass() to register it as application global. If you don’t, you will only be able to instantiate your control manually by passing the DLL’s HMODULE as a parameter to CreateWindow().
By the way, MFC seems to support customizing controls primarily through window subclassing, which is a related but slightly different mechanism.
Recent Comments