Almost all windows UI programmers needed to create custom versions or behavior of standard controls to perform special function.
For simple hackings the control procedure subclassing is enough, but for some more sophisticated modifications we need to handle also the notifications messages.
The problem in this case is that the notification messages, in WM_COMMAND or WM_NOTIFY form, are sent only to the parent window. The solution is to insert the custom handling code inside the parent procedure, or subclass it adding another procedure function.
The result is always complex code difficult to read, debug and maintain, not mentioning the difficulties to route control private data structures and cleaning allocated resources: memory, properties, etc.
Another limitation is the portability, to reuse the customization for other controls requires many tweaking in the program sources.
It would be very nice to code all the custom functions inside the control subclass procedure, possibly with a transparent layer that reflects the window messages to the control subclass procedure and take care of infrastructure creation and cleanup.
To avoid reinventing the wheel, I thoroughly examined several well-established techniques that have been in use for years, observing how they are employed by frameworks such as MFC, ATL, and the like.
I built this simple framework for the code above. It isn't perfect, needs more tests and may get upgrades for added functionalities.
Up to now it works flawlessly for my code.
I share it in the hope that could be of any help to someone else.
P.S. It is freshly written code and I didn't put a lot of comments up to now, but I think it is easily understandable. The AI was of a lot of help to speed-up.
Michele -- Thank you for sharing your library.
When I built my BCX_SPLITBUTTON control and its support function earlier this year,
I learned some lessons about dealing with WM_NOTIFY messages originating in the
parent that needed to be forwarded to the control for processing. If not for AI,
your library would have been very helpful. I'm going to study your code some more
and hopefully learn a few more lessons that will help me in the future.