Page 1 of 1

a visual component creation question..

PostPosted: August 3rd, 2006, 11:01 am
by very angry mobster
Hi all,

I'm starting to program visual components for use in delphi and i've run into a small problem. From what i understand, when drawing the graphics for a control, i should render the graphics on an off-screen bitmap then copy the result to the on-screen control.

my question is, where do i create the off screen bitmap?

my first thought was to create the temp bitmap in the components constructor, but at that stage the components size still has not been set. i then tried to override the width and height properties so that i could change the size of my bitmap when width and height were changed, but that didn't seem to work at all. Is it possible to override a property declared in a components base class?

should the temp bitmap be created at the beginning of the Paint procedure?


cheers,
vam

PostPosted: August 3rd, 2006, 12:38 pm
by Johnny_Bit
Look at already done components and try to learn from them, it's the easiest way... another way is getting some books.

PostPosted: August 4th, 2006, 10:00 am
by Kambiz
Create and destroy the off screen bitmap respectfully in cobstructor and destructor of the component.

If the base control has Resize method, you can override Resize method to set the size of bitmap.

TGraphicControl im older versions of Delphi doesn't have Resize method, therefore you have to set size of the bitmap before drawing on it.

PostPosted: August 4th, 2006, 11:50 am
by very angry mobster
Thanks Johnny and Kambiz.

I only have a few gui components installed. namely the DIB Components by peter morris, which seem to draw straight onto the components canvas. which i thought was a no-no anyway as it can contribute to image flicker. i haven't followed the logic though to the base classes so perhaps i'm wrong about that.


cheers,
vam