Советы по Delphi



         

Label2


Комбинация TLabel и TEdit
unit Editlbl1;

interface

uses

SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,Forms, Dialogs, stdctrls;
type
TLabelEdit = class(TWinControl)private{ Private declarations }FEdit: TEdit;FLabel: TLabel;function GetLabelCaption: string;procedure SetLabelCaption(LabelCaption: string);function GetEditText: string;procedure SetEditText(EditText: string);protected{ Protected declarations }public{ Public declarations }constructor Create(AOwner: TComponent); override;publishedproperty LabelCaption: string read GetLabelCaption write SetLabelCaption;property EditText: string read GetEditText write SetEditText;property Left;property Top;property Width;property Height;property Text;property Font;{ Можете опубликовать другие, необходимые вам свойства. }{ Published declarations }end;
procedure Register;

implementation

constructor
TLabelEdit.Create(AOwner: TComponent);
begin
inherited
Create(AOwner);
FEdit := TEdit.Create(self);FLabel := TLabel.Create(self);
with FLabel do beginWidth := FEdit.Width;visible := true;Parent := self;Caption := 'LabelEdit';end;
with FEdit do beginTop := FLabel.Height+2;Parent := self;Visible := true;end;
Top := 0;Left := 0;Width := FEdit.Width;Height := FEdit.Height+FLabel.Height;Visible := true;end;

function TLabelEdit.GetLabelCaption: string;
begin
Result := FLabel.Caption;end;

procedure TLabelEdit.SetLabelCaption(LabelCaption: string);
begin
FLabel.Caption := LabelCaption;end;

function TLabelEdit.GetEditText: string;
begin
Result := FEdit.Text;end;

procedure TLabelEdit.SetEditText(EditText: string);
begin
FEdit.Text := EditText;end;

procedure Register;
begin
RegisterComponents('Test', [TLabelEdit]);end;

end.
[000481]


Содержание  Назад  Вперед