[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

IdIMAP41.mailboxlist to TTreeNode

Posted on 2003-12-10
4
Medium Priority
?
756 Views
Last Modified: 2010-04-16
Hello, I would convert IdIMAP41 Mailboxlist with all mailboxes and sub mailboxes to a TTreenode, is there any way to do it?
example:  
mailbox1/sub1/sub2/test
mailbox1/sub1/test1
mailbox1
mailbox1/sub1/sub2/test3

to

- mailbox1
  - sub1
       - sub2
             test
             test3
        test1


0
Comment
Question by:k4hvd66
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 9911818
a sample

i have simplfied your content as memo-content

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ComCtrls, StdCtrls;

type
  TForm1 = class(TForm)
    Memo1: TMemo;
    TreeView1: TTreeView;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

function splitstr(var astring : String; Delimiter : String) : String;
var
  p : Integer;
begin
  result := '';
  if AString <> '' then
  begin
    p := pos(Delimiter,AString);
    if p > 0 then
    begin
      result := copy(AString,1,p-1);
      AString := copy(AString,p+length(Delimiter),maxLongInt);
    end
    else
    begin
      result := AString;
      AString := '';
    end;
  end;
end;

Function SearchOrCreateNode(ATree : TTreeView; AParentNode : TTreeNode; ACaption : String) : TTreeNode;
var ANode : TTreeNode;
begin
  result := nil;
  if not assigned(AParentNode) then  //onRoot
  begin
    ANode := ATree.TopItem;
    while (assigned(ANode)) and (ACaption <> ANode.Text) do
      ANode := ANode.getNextSibling;
    if not assigned(ANode) then
      result := ATree.Items.Add(NIL,ACaption)
    else
      result := ANode;
  end
  else
  begin  //OnParent
    ANode := AParentNode.getFirstChild;
    while (assigned(ANode)) and (ACaption <> ANode.Text) do
      ANode := ANode.getNextSibling;
    if not assigned(ANode) then
      result := ATree.Items.AddChild(AParentNode,ACaption)
    else
      result := ANode;
  end;
end;




Procedure FillTree(ATree : TTreeView; AList : TStrings; ADelimiter : String);
var
  I : Integer;
  s, ssplit : string;
  CurrentNode : TTreeNode;
begin
  for i := 0 to AList.Count-1 do
  begin
    s := AList[i];
    CurrentNode := Nil;
    while s <> '' do
    begin
      ssplit := splitstr(s,ADelimiter);
      CurrentNode := SearchOrCreateNode(ATree,CurrentNode,ssplit);
    end;
  end;
end;


procedure TForm1.Button1Click(Sender: TObject);
begin
  FillTree(TreeView1, memo1.Lines, '/');

end;

end.

meikl ;-)
0
 

Author Comment

by:k4hvd66
ID: 9912353
the problem is, I need to add all of this as a child from a TNode so I cannot fill the tree directly, is that possible to get all this in a Node?
0
 
LVL 27

Accepted Solution

by:
kretzschmar earned 760 total points
ID: 9912386
?

TTreeNode must have as Owner TTreeNodes
TTreeNodes must have as Owner TCustomTreeView

all you need is a TTreeview

meikl ;-)
0
 

Author Comment

by:k4hvd66
ID: 9914346
it works!!
Thanks
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question