
19.05.2010, 16:56
|
 |
Let Me Show You
|
|
Регистрация: 30.04.2010
Адрес: Северодвинск
Сообщения: 5,426
Версия Delphi: 7, XE5
Репутация: 59586
|
|
ComponentStack.pas :
PHP код:
unit ComponentStack;
interface
uses
Contnrs,
Classes;
type
TComponentStack = class(TComponent)
private
FStack: TStack;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
function Count: Integer;
function Push(AItem: Pointer): Pointer;
function Pop: Pointer;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Internet', [TComponentStack]);
end;
{ TComponentStack }
constructor TComponentStack.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FStack:=TStack.Create;
end;
destructor TComponentStack.Destroy;
begin
FStack.Free;
inherited Destroy;
end;
function TComponentStack.Count: Integer;
begin
Result:=FStack.Count;
end;
function TComponentStack.Push(AItem: Pointer): Pointer;
begin
Result:=FStack.Push(AItem);
end;
function TComponentStack.Pop: Pointer;
begin
Result:=FStack.Pop;
end;
end.
Unit1.pas :
PHP код:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
StdCtrls, ComponentStack;
type
TForm1 = class(TForm)
ComponentStack1: TComponentStack;
Button1: TButton;
Edit1: TEdit;
Label1: TLabel;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
ComponentStack1.Push(Button1);
ComponentStack1.Push(Edit1);
ComponentStack1.Push(Label1);
Caption:=IntToStr(ComponentStack1.Count);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
if ComponentStack1.Count>0 then
TObject(ComponentStack1.Pop).Free;
Caption:=IntToStr(ComponentStack1.Count);
end;
end.
TComponentStack60.dpk :
PHP код:
package TComponentStack60;
{$R *.res}
{$ALIGN 8}
{$ASSERTIONS ON}
{$BOOLEVAL OFF}
{$DEBUGINFO ON}
{$EXTENDEDSYNTAX ON}
{$IMPORTEDDATA ON}
{$IOCHECKS ON}
{$LOCALSYMBOLS ON}
{$LONGSTRINGS ON}
{$OPENSTRINGS ON}
{$OPTIMIZATION ON}
{$OVERFLOWCHECKS OFF}
{$RANGECHECKS OFF}
{$REFERENCEINFO ON}
{$SAFEDIVIDE OFF}
{$STACKFRAMES OFF}
{$TYPEDADDRESS OFF}
{$VARSTRINGCHECKS ON}
{$WRITEABLECONST OFF}
{$MINENUMSIZE 1}
{$IMAGEBASE $400000}
{$DESCRIPTION 'TComponentStack'}
{$IMPLICITBUILD OFF}
requires
rtl;
contains
ComponentStack in 'ComponentStack.pas';
end.
|