Paint Event of Subclass of a Custom Canvas

I have a custom canvas that has a Paint event. Call it (A).

I subclass that canvas. Call it (B). I want to basically add “some stuff” specifically a Group2D of Object2D’s to the (B) instances. The goal is that when the Paint event occurs it deals with all the issues of the parent (A) and any additional stuff specific to the subclass (B).

How can I make this work? I cannot put a Paint event into (B) because it is a subclass of (A) who has already “claimed” the Paint event.

I have created an Event Definition in (A) and raise that event in the Paint event of (A). That Event Definition is given the parameters of a Paint Event (g As Graphics, areas() As REALbasic.Rect) Then in the subclass (B) I use that event to put in the Group2D group stuff that is unique to (B).

So far this seems to work but I did this reluctantly because now (A) has some special code (RaisingEvent in its Paint code) for the benefit of a subclass that it ideally would not know exists at all. I thought there was some canonical rule that a superclass should not be tasked with worrying about some subclass that might not exist at all in the project.

Is there a more correct or elegant way to accomplish the goal?

I would say that is the right way to do it.

A.Paint does have some code to allow subclasses to have their own Paint event but it doesn’t have to care if the subclasses implement the event or what they do in the event.

if you use the paint event in the custom control than its more hard-coded but always present if you drop it into a window.
or you can use the paint event in the window where the control was placed and call any Method you want in the paint event
that is more neutral.
usually i put the drawing in extra methods with a g as graphics parameter.

i think your extra event is unnecessary because it start from paint event.