unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TForm1 =
class(TForm)
edt1: TEdit;
pb1: TPaintBox;
procedure edt1KeyPress(Sender: TObject;
var Key: Char);
procedure FormCreate(Sender: TObject);
procedure pb1Paint(Sender: TObject);
private
{ Private-Deklarationen }
FRadius: integer;
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.edt1KeyPress(Sender: TObject;
var Key: Char);
begin
if Key = #13
then
begin
Key := #0;
FRadius := StrToIntDef(edt1.Text,0);
pb1.repaint;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
FRadius := 0;
end;
procedure TForm1.pb1Paint(Sender: TObject);
const Start = 100;
var Kantenlaenge: Integer;
begin
with pb1
do
begin
Canvas.Pen.Color := clRed;
SetMapMode(Canvas.Handle, MM_LOMETRIC);
Kantenlaenge := FRadius * 20 + Start;
Ellipse(Canvas.Handle,pb1.Left + Start,-(pb1.Top + Start),pb1.Left + Kantenlaenge,-(pb1.Top + Kantenlaenge));
end;
end;
end.