无法在Delphi 7中使用画布功能 [英] Not able to use canvas function in Delphi 7

查看:41
本文介绍了无法在Delphi 7中使用画布功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始在Delphi 7中学习GDI图形.在主窗体上绘制椭圆,文本等时遇到问题.基本上我使用以下代码:

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');

此Canvas属性是否需要与表单相关联?我还没做那样的事情.帮助将不胜感激.

Is this Canvas Property required to be associated with the Form? I haven't done any thing like that. Help will be appreciated.

推荐答案

确保将所有绘画代码放入表单的 OnPaint 事件处理程序中(

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;

这篇关于无法在Delphi 7中使用画布功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆