| View previous topic :: View next topic |
| Author |
Message |
very angry mobster Member
Joined: 27 Jul 2006 Posts: 3
|
Posted: 03/08/06 11:01 Post subject: a visual component creation question.. |
|
|
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
|
|
| Back to top |
|
 |
Johnny_Bit Moderator
Joined: 15 Jun 2003 Posts: 274
|
Posted: 03/08/06 12:38 Post subject: |
|
|
| Look at already done components and try to learn from them, it's the easiest way... another way is getting some books.
|
|
| Back to top |
|
 |
Kambiz Administrator

Joined: 07 Mar 2003 Posts: 1044 Location: Tehran, Iran
|
Posted: 04/08/06 10:00 Post subject: |
|
|
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 |
|
| Back to top |
|
 |
very angry mobster Member
Joined: 27 Jul 2006 Posts: 3
|
Posted: 04/08/06 11:50 Post subject: |
|
|
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
|
|
| Back to top |
|
 |
|