Показать сообщение отдельно
  #10  
Старый 19.05.2010, 16:56
Аватар для NumLock
NumLock NumLock вне форума
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
    
FStackTStack;
  public
    
constructor Create(AOwnerTComponent); override;
    
destructor Destroyoverride;
    function 
CountInteger;
    function 
Push(AItemPointer): Pointer;
    function 
PopPointer;
  
end;

procedure Register;
  
implementation

procedure Register
;
begin
  RegisterComponents
('Internet', [TComponentStack]);
end;

TComponentStack }

constructor TComponentStack.Create(AOwnerTComponent);
begin
  inherited Create
(AOwner);
  
FStack:=TStack.Create;
end;

destructor TComponentStack.Destroy;
begin
  FStack
.Free;
  
inherited Destroy;
end;

function 
TComponentStack.CountInteger;
begin
  Result
:=FStack.Count;
end;

function 
TComponentStack.Push(AItemPointer): Pointer;
begin
  Result
:=FStack.Push(AItem);
end;

function 
TComponentStack.PopPointer;
begin
  Result
:=FStack.Pop;
end;

end
Unit1.pas :
PHP код:
unit Unit1;

interface

uses
  Windows
MessagesSysUtilsVariantsClassesGraphicsControlsForms,
  
StdCtrlsComponentStack;

type
  TForm1 
= class(TForm)
    
ComponentStack1TComponentStack;
    
Button1TButton;
    
Edit1TEdit;
    
Label1TLabel;
    
Button2TButton;
    
procedure Button1Click(SenderTObject);
    
procedure Button2Click(SenderTObject);
  private
    { Private 
declarations }
  public
    { Public 
declarations }
  
end;

var
  
Form1TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(SenderTObject);
begin
  ComponentStack1
.Push(Button1);
  
ComponentStack1.Push(Edit1);
  
ComponentStack1.Push(Label1);
  
Caption:=IntToStr(ComponentStack1.Count);
end;

procedure TForm1.Button2Click(SenderTObject);
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
Ответить с цитированием