Change ChildManager at runtime

TeeTree VCL for Borland Delphi and C++ Builder.
Post Reply
mivchart
Newbie
Newbie
Posts: 31
Joined: Thu Dec 04, 2008 12:00 am

Change ChildManager at runtime

Post by mivchart » Sun Apr 11, 2010 4:56 pm

Hi,
Delph 2007 and Teetree2 included Teechart Pro VCL 8.04

I try change presentation of Tree by (Explorer, Left , Top or ListView) , at runtime but i have exception.
What is the best practice in this subject ??

My code ================================================================


function TreePrepareManager(ATree:TTree;AChildManager:TObject):integer;
begin
if ATree=nil then exit;
try
// Typ de tree Explorateur ; top ; Left ; ListView (PB not ancestor common!!)
if (AChildManager is TTreeExplorerAlignChild) then
ATree.ChangeManager(AChildManager as TTreeExplorerAlignChild)
else if AChildManager is TTreeTopBottomAlignChild then
ATree.ChangeManager(AChildManager as TTreeTopBottomAlignChild)
else if AChildManager is TTreeLeftRightAlignChild then
ATree.ChangeManager(AChildManager as TTreeLeftRightAlignChild)
else if AChildManager is TTreeListViewAlignChild then
ATree.ChangeManager(AChildManager as TTreeListViewAlignChild);
Except
CT_ERR.Push('U_TreeEfc.pas : Procedure PrepareChildManager'); Raise; // exception vioalion access !!!
End;
end;

in my forms========================================

constructor TFrameEfcTree.Create(AOwner: TComponent);
begin
inherited;
// Format of the tree
ChildExplorateur :=TTreeExplorerAlignChild.Create;
ChildTop :=TTreeTopBottomAlignChild.Create;
ChildLeft :=TTreeLeftRightAlignChild.Create;
ChildList :=TTreeListViewAlignChild.Create;

Tree1.AssignParent:=True;
ChildEnCours := ChildExplorateur; // ChildEnCours is Tobject

end;

procedure TFrameEfcTree.BtExploClick(Sender: TObject);
begin

Tree1.Clear;
ChildEnCours := ChildExplorateur;
TreePrepareManager(Tree1, ChildEnCours );
end;

procedure TFrameEfcTree.BtLeftClick(Sender: TObject);
begin
Tree1.Clear;
ChildEnCours := ChildLeft;
TreePrepareManager(Tree1, ChildEnCours );
end;


But, in first test is OK, but if change 2 o 3 > exception !!

Yeray
Site Admin
Site Admin
Posts: 9614
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Change ChildManager at runtime

Post by Yeray » Mon Apr 12, 2010 11:19 am

Hi mivchart,

Could you please send us a simple example project we can run as-is to reproduce the problem here?
Thanks in advance.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

mivchart
Newbie
Newbie
Posts: 31
Joined: Thu Dec 04, 2008 12:00 am

Re: Change ChildManager at runtime

Post by mivchart » Mon Apr 12, 2010 1:44 pm

Ok, with sample project.
Attachments
ChildManager.zip
Sample Example
(32.92 KiB) Downloaded 1184 times

mivchart
Newbie
Newbie
Posts: 31
Joined: Thu Dec 04, 2008 12:00 am

Re: Change ChildManager at runtime

Post by mivchart » Wed Apr 14, 2010 7:34 am

Do you have solution for me, with example above !

Yeray
Site Admin
Site Admin
Posts: 9614
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Change ChildManager at runtime

Post by Yeray » Thu Apr 15, 2010 1:54 pm

Hi mivchart,

Thanks for the project. We could reproduce the problem and we tried to analyse what's wrong but I'm afraid we couldn't find it.
I've added it to the defect list to be revised deeper so it can be fixed in future releases (TV52014798).
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

mivchart
Newbie
Newbie
Posts: 31
Joined: Thu Dec 04, 2008 12:00 am

Re: Change ChildManager at runtime

Post by mivchart » Thu Apr 15, 2010 3:00 pm

ok,

ok, I'll do differently in this case

mivchart
Newbie
Newbie
Posts: 31
Joined: Thu Dec 04, 2008 12:00 am

Re: Change ChildManager at runtime

Post by mivchart » Fri Apr 16, 2010 2:35 pm

Hi,

i have a solution to every change made in the format, you must recreate a ChilManger, without releasing the previous !
I think the release is done internally

It's simple and it works
I create a type to simplify my code


type TTreeFmtType=(TreeFmtExplo,TreeFmtTop,TreeFmtLeft,TreeFmtList);

//=======================================

procedure TFrameEfcTree.TreeChangeFormat;
begin
try
//change la Forme du Tree
case TreeFormat of
TreeFmtExplo: Tree1.ChangeManager(TTreeExplorerAlignChild.Create);
TreeFmtTop: Tree1.ChangeManager(TTreeTopBottomAlignChild.Create);
TreeFmtLeft: Tree1.ChangeManager(TTreeLeftRightAlignChild.Create);
TreeFmtList: Tree1.ChangeManager(TTreeListViewAlignChild.Create);
end; //case

except
On E:Exception do Showmessage(E.Message);
end;
end;

Post Reply