岩
岩军
Unregistered / Unconfirmed
GUEST, unregistred user!
unit pictureUit;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
PaintBox1: TPaintBox;
procedure FormCreate(Sender: TObject);
procedure PaintBox1Paint(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
Shape: Tshape;
implementation
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
begin
shape:=4
end;
procedure TForm1.PaintBox1Paint(Sender: TObject);
begin
With Sender as TPaintBox1 do
if Shape=1 then
begin
Canvas.Ellipse(0,0,30,30);
end
if shape=2 then
begin
Canvas.pen.Color:=clRed;
Canvas.Polyline([Point(40,10),Point(20,60),
Point(70,30),Point(60,60),Point(40,10)]);
end
else
begin
if shape=3 then
begin
Canvas.pen.Color:=clBlue;
Canvas.Rectangle(0,0,30,30);
end;
end;
end;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Shape:=1;
PaintBox1.Repaint;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Shape:=2;
PaintBox1.Repaint;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
Shape:=3;
PaintBox1.Repaint;
end;
end.
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
PaintBox1: TPaintBox;
procedure FormCreate(Sender: TObject);
procedure PaintBox1Paint(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
Shape: Tshape;
implementation
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
begin
shape:=4
end;
procedure TForm1.PaintBox1Paint(Sender: TObject);
begin
With Sender as TPaintBox1 do
if Shape=1 then
begin
Canvas.Ellipse(0,0,30,30);
end
if shape=2 then
begin
Canvas.pen.Color:=clRed;
Canvas.Polyline([Point(40,10),Point(20,60),
Point(70,30),Point(60,60),Point(40,10)]);
end
else
begin
if shape=3 then
begin
Canvas.pen.Color:=clBlue;
Canvas.Rectangle(0,0,30,30);
end;
end;
end;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Shape:=1;
PaintBox1.Repaint;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Shape:=2;
PaintBox1.Repaint;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
Shape:=3;
PaintBox1.Repaint;
end;
end.