Adv(Directory)TreeView

Hello,

I started work with (TAdvDirectory) TreeView yet, and have two basic problems for acceptance of this components.

  1. How can I activate the Node.Selection by MouseDown (and not by MouseUp)? Just like the most explorers.
  2. If there is a empty directory (node) there is shown the "+" Icon first, until it will be clicked.
Thank you for help.

Peter

Hi, 


1) This is currently not possible. The implementation has been done with mouse-up instead. We will investigate if we can improve this behavior.

2) This is by design, the content of the directory will be loaded when clicked. And if the content doesn't contain files or folders, the node icon disappears.

Hello,

1) What a pity.
2) Is there a simple way to do this by iteration over all nodes without analyze and understanding the TMS code philosophy.

Thanks
Peter

Hi, 


You could accomplish this with the following code (implement the OnBeforeDrawNodeExpand)

uses
  IOUtils;

procedure TForm1.AdvDirectoryTreeView1BeforeDrawNodeExpand(Sender: TObject;
  ACanvas: TCanvas; ARect: TRectF; AColumn: Integer;
  ANode: TAdvTreeViewVirtualNode; AExpand: TPicture; var AAllow: Boolean);
var
  d: string;
begin
  d := TAdvDirectoryTreeViewNode(ANode.Node).FileName;
  AAllow := TDirectory.Exists(d) and not TDirectory.IsEmpty(d);
end;


Hello,

2) It works well.
1) Is there also a simple way to "patch" the Code, pherhaps in OnMouseDown? I think one way could be to create a new descendant of this component (for using virtual and protected) and build a new "HandleMouseUp", called by MouseDown. Is that a stupid or possible Idea?

Thanks.
Peter

Hi, 


You could indeed use the following code to redirect the HandleMouseDown / HandleMouse

type
  TAdvDirectoryTreeViewEx = class(TAdvDirectoryTreeView)
  protected
    procedure HandleMouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Single); override;
    procedure HandleMouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Single); override;
  end;

...

implementation

...

{ TAdvDirectoryTreeViewEx }

procedure TAdvDirectoryTreeViewEx.HandleMouseDown(Button: TMouseButton;
  Shift: TShiftState; X, Y: Single);
begin
  inherited HandleMouseDown(Button, Shift, X, Y);
  inherited HandleMouseUp(Button, Shift, X, Y);
end;

procedure TAdvDirectoryTreeViewEx.HandleMouseUp(Button: TMouseButton;
  Shift: TShiftState; X, Y: Single);
begin
//
end;

procedure TForm1.FormCreate(Sender: TObject);
var
  d: TAdvDirectoryTreeViewEx;
begin
  d := TAdvDirectoryTreeViewEx.Create(Self);
  d.Parent := Self;
  d.InitSample;
  d.LoadDrive('C:', True);
end;

Hello,

it works well. A helpful change is to use the original Component at designtime and clone it in Create to the new descendant. Now I can manipulate a lot of features inside with all the comfort at designtime. And without installing a new component.

Thanks.
Peter

Thank you for your feedback!