Part of the development of one of my pet projects, the UML Designer, requires some type of custom canvas to display the UML graphs. Sounds easy, especially since I’ve done similar things in Java. Unfortunately reality proves me wrong every time.
I started out by creating a custom component, which inherits from the Panel. This would give me pretty much a blank object that could be added to the GUI. The painting part on its own is not that difficult either. Done that hundreds of times. The problem is in adding the various objects to paint on top of the panel to the panel before drawing commences.
Ok, I’ll try to explain a little better. I keep track of what to draw in an array inside the custom panel. This because these objects contain more information then just how to draw. But they are not part of the component list of the panel. I need to add them dynamically just before drawing and remove them again after drawing. But I’ve yet to find the correct way of doing this.
Tried adding them in the onPaint method, but this doesn’t trigger them to be painted. So I’ll probably have to intercept the WM_PAINT message sent to the panel and attach the