unit FMMoveMessage;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  GradForm,
  ComCtrls, TreeViewEx, StdCtrls, ExtCtrls, IniFiles;

type
  TfrmMoveMessage = class(TdfsGradientForm)
    TreeView1: TPMTreeViewEx;
    btnCancle: TButton;
    btnConfirm: TButton;
    Label1: TLabel;
    btnNewFold: TButton;
    procedure TreeView1Change(Sender: TObject; Node: TTreeNode);
    procedure TreeView1DblClick(Sender: TObject);
    procedure btnConfirmClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    CurrentDir: string;
    function GetSelectedPath: string;
    function GetSearchPathName: string;
    function GetSelectedAccount : TTreeNode;
  end;

var
  frmMoveMessage: TfrmMoveMessage;

implementation

{$R *.DFM}

uses
  Main, PXStuff;

function TfrmMoveMessage.GetSelectedAccount : TTreeNode;
begin
  Result := nil;
  if Assigned(TreeView1.Selected) then
  begin
    Result := GetSelectedAccountNode(Treeview1.Selected);
  end;
end;

function TfrmMoveMessage.GetSelectedPath: string;
begin
  try
    // AHRJ05--
    Result := GetNodeDirName(TreeView1.Selected);
  except
    Result := sAccountRootFolder;
  end;
end;

function TfrmMoveMessage.GetSearchPathName: string;
var
  tmp: string;
  nd: TTreeNode;
begin
  nd := TreeView1.Selected;
  while nd <> nil do begin
    tmp := nd.Text + '\' + tmp;
    nd := nd.Parent;
  end;
  Result := tmp;
end;

procedure TfrmMoveMessage.TreeView1Change(Sender: TObject;
  Node: TTreeNode);
begin
  if CurrentDir <> '' then
    btnConfirm.Enabled := (Node.StateIndex <> tnAccount) and
      (Node.StateIndex <> tnAccounts); //and
//      (CompareText(GetSelectedPath, CurrentDir) <> 0);
end;



procedure TfrmMoveMessage.TreeView1DblClick(Sender: TObject);
begin
  ModalResult := mrOK;
end;

procedure TfrmMoveMessage.btnConfirmClick(Sender: TObject);
begin
    ActiveAccount := MainForm.GetActiveAccount(TreeView1.Selected);
end;

initialization
   PMRegistry.AddCustomClass(TfrmMoveMessage, 'TFMMoveMessageForm');

end.
