Custom Component - Where's the canvas?
Posted on 2006-10-31
I'm creating a new custom components (TCustomControl decendent) in BDS2006 (.Net for VCL). I have a procedure which is called with the components caption is changed. This procedure needs the Canvas to be available as it uses the TextHeight and TextWidth to work out the co-ordinates for the new caption.
The problem is, when I first drop the component onto a form, I get an exception because the canvas isn't available. Here's the order that things are done:
1. Drop component on form
2. Create method called
3. Caption is set to a default
4. Event triggered for set_Caption
5. ProcessCaption procedure is called
I'd be hoping that there'd be a:
6. Control is painted.
What have I got to do to be a ble to get the canvas to be available to the control in more places than just the Paint procedure? Do I need to declare it as a property or something?