我想在窗体上画一个圆和一条直线.如何作到?(15分)

  • 主题发起人 主题发起人 renxiaoyaolixia
  • 开始时间 开始时间
R

renxiaoyaolixia

Unregistered / Unconfirmed
GUEST, unregistred user!
我想在窗体上画一个圆和一条直线.如何作到?
 
可以用shape控件
 
用form的canvas直接做图就可以了
 
能说的更清楚一点吗?我有急用。谢谢!
 
form1.Canvas.Ellipse(0,0,100,100); //以(0,0)为左上坐标,(100,100)为右下
坐标的矩形区域内画一个内切圆。
form1.canvas.moveto(0,0);
form1.canvas.lineto(100,100);//画就条就(0,0)为起点,(100,100)为终点的直线
 
在Canvas上直接画就可以了
----------------------
水晶控件
http://www.codeidea.com
 
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls;

type
TForm1 = class(TForm)
Timer1: TTimer;
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Timer1Timer(Sender: TObject);
var
x:integer;
y:integer;
begin
X := Random(Screen.Width - 10);
Y := Random(Screen.Height - 10);
Canvas.Pen.Color := Random(65535);
case Random(5) of
0: Canvas.Pen.Style := psSolid;
1: Canvas.Pen.Style := psDash;
2: Canvas.Pen.Style := psDot;
3: Canvas.Pen.Style := psDashDot;
4: Canvas.Pen.Style := psDashDotDot;
end;
Canvas.Ellipse(X, Y, X + Random(400), Y + Random(400));
canvas.moveto(x,y);
canvas.lineto(X + Random(400),Y + Random(400));//画条就(x,y)为起点,(Random(400),Random(400))为终点的直线
end;

end.
 
后退
顶部