Einzelnen Beitrag anzeigen

Benutzerbild von Wasserratte
Wasserratte

Registriert seit: 25. Apr 2004
Ort: Hildesheim
6 Beiträge
 
#6

Re: Komplexere Variante Records für Linie, Kreis und Rechtec

  Alt 24. Mai 2004, 15:25
Der Variante Record müsste so vollständig sein
Delphi-Quellcode:
type
  TLinie = record
             X1, Y1,
             X2, Y2,
             Width : Integer;
           end;

  TFormList = (Linie, Kreis, Rechteck);
  TFigure = record
               Status : TFormList;
               case TFormList of
                 Linie : ( TLinie : Integer); // Linie
                 Kreis : ( Xm, Ym, Radius : Integer); // Kreis
                 Rechteck : ( P1, Q1, P2, Q2 : Integer); // Rechteck
               end;

implementation

{$R *.dfm}

var
  Zeichnungsdaten : array [0..10] of TFigure;
  F1, F2, F3, F4 : TFigure;
Ist meine Procedure auch richtig? Da muss noch was fehlen

Delphi-Quellcode:
procedure TMain.Btn_LinieClick(Sender: TObject);
var
  X1, Y1, X2, Y2 : Integer;

begin
  Btn_Linie.Enabled := False;
  with Zeichnungsdaten[0] do
    case Status of

    Linie : begin
                 F1.TLinie := 22;
               end;

    Kreis : begin
                 F1.Xm := 10;
                 F2.Ym := 20;
                 F3.Radius := 30;
               end;

    Rechteck : begin
                 F1.P1 := 20;
                 F2.Q1 := 30;
                 F3.P2 := 40;
                 F4.Q2 := 50;
               end;
  end;
  Btn_Linie.Enabled := true;
end;
  X1 := StrToInt( SpEd_X1.Text);
  Y1 := StrToInt( SpEd_Y1.Text);
  X2 := StrToInt( SpEd_X2.Text);
  Y2 := StrToInt( SpEd_Y2.Text);

  with Main.Image.Canvas do
    begin
      MoveTo( X1, Y1);
      LineTo( X2, Y2);
    end;
Nur Nixen konnte nach China gehn!
  Mit Zitat antworten Zitat