Einzelnen Beitrag anzeigen

EWeiss
(Gast)

n/a Beiträge
 
#6

AW: Property mit Record als Typ in Klasse verwenden

  Alt 19. Jul 2018, 07:44
Zitat:
Gibts aber z.B. eine zweite Klasse:
Nun das wäre dann eine
Denn bei ihr sind es zwei records.

simple sample..
Delphi-Quellcode:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TMyRecord = record
  private
    FTotalWidth : integer;
    procedure SetTotalWidth(const Value: Integer);
  public
    property TotalWidth : Integer read FTotalWidth write SetTotalWidth;
  end;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Label1: TLabel;
    procedure Button1Click(Sender: TObject);
  private
    { Private-Deklarationen }
    FMyRecord : TMyRecord;
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
    FMyRecord.TotalWidth := 21;
    Label1.Caption := IntToStr(FMyRecord.TotalWidth);
end;

{ TMyRecord }

procedure TMyRecord.SetTotalWidth(const Value: Integer);
begin

  FTotalWidth := Value;
end;

end.
Egal.. sie\er soll sich aussuchen was er will.

gruss

Geändert von EWeiss (19. Jul 2018 um 08:49 Uhr)
  Mit Zitat antworten Zitat