unit1.pas
来自「学习Delphi最好的教材。通过一个个简单而实用的实例」· PAS 代码 · 共 67 行
PAS
67 行
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
ListBox1: TListBox;
Button4: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
Canvas.MoveTo(20,20); //先把画笔移到点(20,20) ,直线的起点
Canvas.LineTo(200,20); //画直线到(200,20) ,直线的终点
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Canvas.Rectangle(20,40,200,60);
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
Canvas.Ellipse(20,40,200,60);
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
if ListBox1.ItemIndex=0 then
begin
Canvas.MoveTo(20,20); //先把画笔移到点(20,20) ,直线的起点
Canvas.LineTo(200,20); //画直线到(200,20) ,直线的终点
end;
if ListBox1.ItemIndex=1 then
begin
Canvas.Rectangle(20,40,200,60);
end;
if ListBox1.ItemIndex=2 then
begin
Canvas.Ellipse(20,40,200,60);
end;
end;
end.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?