home *** CD-ROM | disk | FTP | other *** search
- unit Main;
-
- { Program copyright (c) 1995 by Charles Calvert }
- { Project Name: PROPS }
-
- { Very simple minded example showing how to use
- and create a property. The property shown here
- has nothing to do with the Height property that
- is part of a TForm. }
-
- interface
-
- uses
- WinTypes, WinProcs, SysUtils,
- Classes, Graphics, Forms,
- Controls, StdCtrls;
-
- type
- TForm1 = class(TForm)
- BSetHeight: TButton;
- BGetHeight: TButton;
- Edit1: TEdit;
- procedure BGetHeightClick(Sender: TObject);
- procedure FormCreate(Sender: TObject);
- procedure BSetHeightClick(Sender: TObject);
- private
- FHeight: Integer;
- function GetHeight: Integer;
- procedure SetHeight(NewHeight: Integer);
- public
- property Height: Integer read GetHeight write SetHeight;
- end;
-
- var
- Form1: TForm1;
-
- implementation
-
- {$R *.DFM}
-
- procedure TForm1.SetHeight(NewHeight: Integer);
- begin
- FHeight := NewHeight;
- end;
-
- function TForm1.GetHeight: Integer;
- begin
- GetHeight := FHeight;
- end;
-
- procedure TForm1.FormCreate(Sender: TObject);
- begin
- FHeight := 2;
- Edit1.Text := '';
- end;
-
- procedure TForm1.BGetHeightClick(Sender: TObject);
- var
- S: String;
- begin
- S := IntToStr(GetHeight);
- Edit1.Text := S;
- end;
-
- procedure TForm1.BSetHeightClick(Sender: TObject);
- begin
- Height := StrToInt(Edit1.Text);
- Edit1.Text := '';
- end;
-
- end.
-