Как объединить два визуальных VCL компонента
Реализация:
unit TestEdit; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TTestEdit = class(TEdit) private FButton: TButton; protected procedure ButtonClick(Sender: TObject); public constructor Create( AOwner: TComponent ); override; published end; procedure Register; implementation procedure TTestEdit.ButtonClick(Sender: TObject); begin Text := DateToStr(Now); end; constructor TTestEdit.Create( AOwner: TComponent ); begin inherited Create(AOwner); Text := DateToStr(Now); FButton := TButton.Create( self ); FButton.Visible := true; FButton.Parent := self; FButton.Height := Height - 2; FButton.Width := Height - 2; FButton.Left := Width - Height - 2; FButton.top := top; FButton.OnClick := ButtonClick; end; procedure Register; begin RegisterComponents('Standard', [TTestEdit]); end; end.
Комментарии