a visual component creation question..

Please discuss general Delphi programming topics here.

a visual component creation question..

Postby very angry mobster » August 3rd, 2006, 11:01 am

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
very angry mobster
Member
Member
 
Posts: 3
Joined: July 27th, 2006, 3:48 pm

Postby Johnny_Bit » August 3rd, 2006, 12:38 pm

Look at already done components and try to learn from them, it's the easiest way... another way is getting some books.
Johnny_Bit
VIP Member
VIP Member
 
Posts: 455
Joined: June 15th, 2003, 9:56 am

Postby Kambiz » August 4th, 2006, 10:00 am

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.
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2429
Joined: March 7th, 2003, 7:10 pm

Postby very angry mobster » August 4th, 2006, 11:50 am

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
very angry mobster
Member
Member
 
Posts: 3
Joined: July 27th, 2006, 3:48 pm


Return to Delphi Programming

Who is online

Users browsing this forum: No registered users and 1 guest

cron