How would I subclass a canvas to give it a "resized" or "resizing" event handler?

For example, I have a canvas on a window and have an “Inspector panel” which can come in from the right and when that happens the canvas which was say the width of the window is now the width of the window minus the width of the inspector panel.

So, the window is not resized, but the canvas is and I’d like to have an event handler on the canvas for this that will scale the canvas.backdrop picture to fit the new size.

I wouldn’t use a backdrop but the paint event and there simply draw the contents in the size needed.

Ok, but can I add some kind of event to tell when this needs to be done?

As far as the backdrop, actually I’m adding a picture property as the backdrop obvsiously can get smaller, and using it when the canvas gets bigger results in pixelated image.

So, when the size of the canvas changes, I want to run a method that will take the picture stored in the property and make it the right size for the new canvas size and then set the resulting picture as the new backdrop.

The Paint event will be called when a resize happens. So have two private properties like mLastWidth As Integer and mLastHeight As Integer and check in the Paint event, if the width or height has changed.

Event Paint() If mLastWidth <> Me.Width Or mLastHeight <> Me.Height Then // Canvas has been resized ... do something ... mLastWidth = Me.Width mLastHeight = Me.Heigh End ... End

Great thanks Eil, I’ll try that.