| View previous topic :: View next topic |
| Author |
Message |
aa Guest
|
Posted: Mon Oct 27, 2003 7:12 pm Post subject: PaintBox & redraw problem |
|
|
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
|
Posted: Mon Oct 27, 2003 7:48 pm Post subject: Re: PaintBox & redraw problem |
|
|
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
|
Posted: Mon Oct 27, 2003 9:25 pm Post subject: Re: PaintBox & redraw problem |
|
|
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 |
|
 |
|