Einzelnen Beitrag anzeigen

me123

Registriert seit: 6. Mär 2012
5 Beiträge
 
#3

AW: Delphi XE2 Canvas Fehler, die keine sind

  Alt 6. Mär 2012, 13:24
Delphi-Quellcode:
unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ExtCtrls;

type
  TForm1 = class(TForm)
    procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
    procedure FormPaint(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  FMain: TForm1;
  x,y,big:word;

implementation
{$R *.dfm}

procedure clearCanvas();
begin
  FMain.Canvas.Brush.Color := clBtnFace;
  FMain.Canvas.FillRect(FMain.Canvas.ClipRect);
end;

procedure enter();
begin
  clearCanvas();
  if big >= 5 then
  begin
    big := big - 5;
    FMain.Canvas.Ellipse(x,y,big+x,big+y);
  end;
end;

procedure leer();
begin
  clearCanvas();
  big := big + 5;
  FMain.Canvas.Ellipse(x,y,big+x,big+y);
end;

procedure links(var x:word);
begin
  clearCanvas();
  dec(x);
  FMain.Canvas.Ellipse(x,y,big+x,big+y);
end;

procedure hoch(var y:word);
begin
  clearCanvas();
  dec(y);
  FMain.Canvas.Ellipse(x,y,big+x,big+y);
end;

procedure rechts(var x:word);
begin
  clearCanvas();
  inc(x);
  FMain.Canvas.Ellipse(x,y,big+x,big+y);
end;

procedure runter(var y:word);
begin
  clearCanvas();
  inc(y);
  FMain.Canvas.Ellipse(x,y,big+x,big+y);
end;

procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if (x > 0) AND (y > 0) then
  begin
    case Key of
    13: enter();
    32: leer();
    37: links(x);
    38: hoch(y);
    39: rechts(x);
    40: runter(y);
    end;
  end
  else
  begin
    if x <= 0 then
      x := 1;
    if y <= 0 then
      y := 1;
  end;
end;

procedure TForm1.FormPaint(Sender: TObject);
begin
  FMain.Canvas.Ellipse(x,y,big+x,big+y);
end;

initialization
x := 200;
y := 200;
big := 20;

end.
  Mit Zitat antworten Zitat