Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VCL event implemented in a form.

Status
Not open for further replies.

rcloutie

Programmer
May 26, 2005
164
CA
Hi,

I've developed a VCL based on TStringGrid and put some code within my VCL's DrawCell event. All works fine.

In one form, I need to draw red lines; so need the event DrawCell to be implemented also in my form. In this specific case, the DrawCell of the VCL is discarted. I tried to call inherited after/before without any results...

Any ideas for the event to be called twice?

Thanks in advance,
 
If you want to perform customized painting on a form you should put your code inside OnPaint event of the form:

For example the following code draws a series of horizontal lines on the form. You can use forms Canvas drawing routines to draw what you like.

You can also use visual form properties such as
ClientHeight, ClientWidth to position or scale your graphical drawings based on the forms area.


procedure TForm2.FormPaint(Sender: TObject);
var
x,y:integer;
begin
//Prepare pen with red color
Canvas.Pen.Color:=$000000FF;

x:=0;
y:=0;

while y<ClientHeight do
begin
//Point the pen to (x,y)
Canvas.MoveTo(x,y);

//Draw the line from (x,y) to (ClientWidth,y)
Canvas.LineTo(ClientWidth,y);

y:=y+10;
end;
end;


See also the help for OnPaint event of TForm.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top