问题
I am beginning to learn GDI graphics in Delphi 7. I am having problems in drawing Ellipses , Text etc. on my Main form. Basically I use this code:
Form1.Canvas.TextOut(10,10,'sss');
Is this Canvas Property required to be associated with the Form? I haven't done any thing like that. Help will be appreciated.
回答1:
Make sure you put all painting code in the form's OnPaint event handler (documentation). This handler is called whenever the form needs to be repainted.
procedure TForm1.FormPaint(Sender: TObject);
begin
Canvas.TextOut(10,10,'sss');
end;
来源:https://stackoverflow.com/questions/7147045/not-able-to-use-canvas-function-in-delphi-7