BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

PaintBox & redraw problem

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi VCL Components Using
View previous topic :: View next topic  
Author Message
aa
Guest





PostPosted: Mon Oct 27, 2003 7:12 pm    Post subject: PaintBox & redraw problem Reply with quote



Hi:

I'm trying to write a simple program that will display a green box twice as
wide as the form at start up. I've dropped a paint box on the form and have
the following code:

procedure TForm1.FormCreate(Sender: TObject);
begin
pb.width := form1.width*2;
pb.height := 300;
pb.Left := 10;
pb.top := 10;
end;

procedure TForm1.FormPaint(Sender: TObject);
begin
with form1.canvas do begin
brush.color := clwhite;
fillrect(clientrect);
end;

with pb.canvas do begin
brush.color := clgreen;
fillrect(boundsrect);
end;
end;


I expected to see the green box as soon as I run the exe. I don't see it
until I maximize the form though. It is also very inconsistent when I
resize the different sides of the form. I doesn't redraw as I would expect.

Any help is greatly appreciated.

Alan


Back to top
D Whaley
Guest





PostPosted: Mon Oct 27, 2003 7:48 pm    Post subject: Re: PaintBox & redraw problem Reply with quote



Part of your problem is here...

with pb.canvas do begin
brush.color := clgreen;
fillrect(boundsrect);

tCanvas does not have a boundsrect, need to change this to clientrect also
or do pb.boundsrect.


Back to top
Sarfraz Bokhari
Guest





PostPosted: Mon Oct 27, 2003 9:25 pm    Post subject: Re: PaintBox & redraw problem Reply with quote



Hi,
Also set DooubleBuffer to True for flicker free.
Good luck

S Bokhari

"aa" <ara2060 (AT) earthlink (DOT) net> wrote

Quote:
Hi:

I'm trying to write a simple program that will display a green box twice
as
wide as the form at start up. I've dropped a paint box on the form and
have
the following code:

procedure TForm1.FormCreate(Sender: TObject);
begin
pb.width := form1.width*2;
pb.height := 300;
pb.Left := 10;
pb.top := 10;
end;

procedure TForm1.FormPaint(Sender: TObject);
begin
with form1.canvas do begin
brush.color := clwhite;
fillrect(clientrect);
end;

with pb.canvas do begin
brush.color := clgreen;
fillrect(boundsrect);
end;
end;


I expected to see the green box as soon as I run the exe. I don't see it
until I maximize the form though. It is also very inconsistent when I
resize the different sides of the form. I doesn't redraw as I would
expect.

Any help is greatly appreciated.

Alan





Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi VCL Components Using All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.