Dr. Dobb's Journal September 1997
Creating a Custom Tree Control Using the SDK
The techniques presented here can be applied to an SDK custom control as well. When using the SDK without MFC, however, some special considerations will apply.
Unlike the MFC approach, each SDK custom control will need to be explicitly subclassed from an existing tree-view control. An in-depth discussion on window subclassing is beyond the scope of this article. For more information on subclassing, however, see "Windows 95 Subclassing and Superclassing," by Jeffrey Richter and Jonathan Locke (Dr. Dobb's Sourcebook, March/April 1996).
Your subclassed window procedure will need to respond to the WM_ PAINT and WM_NOTIFY messages in much the same way that the CCustomTreeCtrl does. Much of the code will port fairly easily, but without MFC, you will not have a simple way of storing the strings for each item.
If you are not using C++, you will probably want to send a WM_DRAWITEM message to the window's parent for each item that needs to be drawn. This means that you need to include the information for redrawing the item in a DRAWITEMSTRUCT. This way, your subclassed control will behave like other owner-draw-capable controls.
-- J.C.
Copyright © 1997, Dr. Dobb's Journal