Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2007.03.18;
Скачать: CL | DM;

Вниз

problema s pointerom   Найти похожие ветки 

 
Adil ©   (2006-06-07 22:46) [0]

Etot urodec daet mne oshibku na showmessage(root^.Parent.ClassName);

Pls, help. Thanks

////////////////////////////////////////////////////////
//     TAdilTaskBar Component                         //
//                                                    //
//     This component is for creating TaskBar         //
//     panel of your application forms.               //
//                                                    //
//                                                    //
//     Copyright 2006, Adil Aliev                     //
//     E-mail: adilaliev@users.sourceforge.net        //
//                                                    //
//                                                    //
////////////////////////////////////////////////////////

unit AdilTaskbarPanel;

interface

uses
 SysUtils, Classes, Controls, ExtCtrls, TntExtCtrls, TntControls, Graphics, TntButtons,Dialogs;

type
 TAdilTaskbarPanel=class;
 
 TAdilTaskBarButton = class(TCollectionItem)
 private
   { Private declarations }
   FCaption: TWideCaption;
   FSpeedButton:TTntSpeedButton;
   procedure SetCaption(Value: TWideCaption);
   function GetGlyph:TBitmap;
   procedure SetGlyph(Value: TBitmap);
 protected
   { Protected declarations }
 public
   { Public declarations }
   constructor Create(Collection : TCollection); override;
   destructor Destroy; override;
 published
   { Published declarations }
   property Caption: TWideCaption read FCaption write SetCaption;
//    property Icon: TBitmap read GetGlyph write SetGlyph;
 end;

 TAdilTaskbarButtons = class(TCollection)
 private
   { Private declarations }

   procedure SetItem(Index:integer;Value:TAdilTaskBarButton);
   function GetItem(Index:integer):TAdilTaskBarButton;
 protected
   { Protected declarations }
   procedure Update(TaskBarButton:TAdilTaskBarButton);
 public
   { Public declarations }
   constructor Create(TaskBar:TAdilTaskbarPanel);
   function Add:TAdilTaskBarButton;
   property TaskbarButtons[Index:integer]:TAdilTaskBarButton read GetItem write SetItem; default;
 published
   { Published declarations }

 end;

 TAdilTaskbarPanel = class(TTntPanel)
 private
   { Private declarations }
   FTaskBarButtons:TAdilTaskbarButtons;
   procedure SetTaskBarButtons(Value:TAdilTaskbarButtons);
   procedure UpdateTaskBarButton(Index:integer);
 protected
   { Protected declarations }
 public
   { Public declarations }
   constructor Create(AOwner:TComponent);override;
   destructor Destroy; override;
   procedure GetChildren(Proc:TGetChildProc; Root:TComponent); override;
 published
   { Published declarations }
   property TaskBarButtons:TAdilTaskBarButtons read FTaskBarButtons write SetTaskBarButtons;

 end;

procedure Register;

implementation
var root:^TAdilTaskbarPanel;
last:integer=1;

constructor TAdilTaskBarButton.Create(Collection : TCollection);
begin
   showmessage(root^.Parent.ClassName);

{    FSpeedButton:=TTntSpeedButton.Create(root^);
{    FSpeedButton.Caption:=FCaption;
   FSpeedButton.Name:="AdilButton"+inttostr(last);
   FSpeedButton.Parent:=root^;
   FSpeedButton.Top:=3;
   FSpeedButton.Left:=last*150;
   inc(last);
   FSpeedButton.Width:=145;
   FSpeedButton.Height:=23;

}
   inherited Create(Collection);
end;

destructor TAdilTaskBarButton.Destroy;
begin
   inherited Destroy;
end;

procedure TAdilTaskBarButton.SetCaption(Value: TWideCaption);
begin
   FCaption:=Value;
//    FSpeedButton.Caption:=Value;
end;

function TAdilTaskBarButton.GetGlyph:TBitmap;
begin
//    Result:=FSpeedButton.Glyph;
end;

procedure TAdilTaskBarButton.SetGlyph(Value: TBitmap);
begin

//    FSpeedButton.Glyph:=Value;
end;

constructor TAdilTaskBarButtons.Create(TaskBar:TAdilTaskbarPanel);
begin
   inherited Create(TAdilTaskBarButton);
end;

procedure TAdilTaskbarButtons.SetItem(Index:integer;Value:TAdilTaskBarButton);
begin
   inherited SetItem(Index,Value);
end;

function TAdilTaskbarButtons.GetItem(Index:integer):TAdilTaskBarButton;
begin
   Result:=TAdilTaskBarButton(inherited GetItem(Index));
end;

procedure TAdilTaskBarButtons.Update(TaskBarButton:TAdilTaskBarButton);
begin
//    if TaskBarButton<>nil then

end;

function  TAdilTaskbarButtons.Add:TAdilTaskBarButton;
begin
   Result:=TAdilTaskBarButton(inherited Add);
end;

constructor TAdilTaskbarPanel.Create(AOwner:TComponent);
begin
   inherited Create(AOwner);
   FTaskBarButtons:=TAdilTaskbarButtons.Create(self);
   root:=@AOwner;
   showmessage("Salam");
end;

destructor TAdilTaskbarPanel.Destroy;
begin
   inherited Destroy;

end;

procedure TAdilTaskbarPanel.SetTaskBarButtons(Value:TAdilTaskBarButtons);
begin
   FTaskBarButtons.Assign(Value);
end;

procedure TAdilTaskbarPanel.GetChildren(Proc:TGetChildProc; Root:TComponent);
begin
   
end;

procedure TAdilTaskbarPanel.UpdateTaskBarButton(Index:integer);
begin
   
end;

procedure Register;
begin
 RegisterComponents("Adil Components", [TAdilTaskbarPanel]);
end;

end.


 
Adil ©   (2006-06-07 23:53) [1]

Вообще то такие вещи делается по другому немножечко.


 
ЮЮ ©   (2006-06-08 06:45) [2]

Во первых, достаточно
root: TAdilTaskbarPanel;
ибо root и есть УКАЗАТЕЛЬ на объект класса  TAdilTaskbarPanel

Во вторых, не здесь не место глобальным переменным
var
 root: TAdilTaskbarPanel;
 last: integer;

Ибо, создав 2 экземпляра класса, получишь непредсказуемое поведение обоих объектов


 
Юрий Зотов ©   (2006-06-08 07:06) [3]

В третьих, root надо выкинуть совсем, а вместо него наследовать коллекцию от TOwnedCollection. В четвертых, свойство Caption элемента коллекции есть смысл делать не отдельным, а завязать на свойство DisplayName.


 
Adil ©   (2006-06-10 18:24) [4]

spasibo



Страницы: 1 вся ветка

Текущий архив: 2007.03.18;
Скачать: CL | DM;

Наверх




Память: 0.48 MB
Время: 0.043 c
2-1172487297
Bogdan1024
2007-02-26 13:54
2007.03.18
АКФ


2-1172600453
Lonix
2007-02-27 21:20
2007.03.18
Запись в файл


2-1172349879
spyrytus
2007-02-24 23:44
2007.03.18
Как узнать что нибуть по кнопкам


2-1171884428
form1
2007-02-19 14:27
2007.03.18
INI + Form


2-1172406975
Kolan
2007-02-25 15:36
2007.03.18
Memo.Lines.AddStrings долго отображает если много строк.