L
lizheng
Unregistered / Unconfirmed
GUEST, unregistred user!
procedure TMainForm.InterLoadFiles;
var
RootNode, CDNode : TTreeNode;
CDName,UpPath : string;
Procedure Add(UpNode:TTreeNode;UpPath:String);
Var
FileNode:TTreeNode;
Path:String;
Begin
With FileDataModule Do
Begin
If UpPath<>'*' Then
FileTable.Filter:=Format('光盘名称=''%s'' AND 所属文件夹=''%s'' AND 文件类型=''文件夹''', [CDName,UpPath]);
FileTable.First;
While Not FileTable.EOF Do
Begin
Path := FileDataModule.FileTable[ '所属文件夹' ] ;
FileNode := TreeView.Items.AddChildObject( UpNode,
FileDataModule.FileTable[ '文件名称' ],
Pointer(Path));
ShowMessage(Path);
ShowMessage(String(FileNode.Data));
~~~~~~~~~~~~~~~~~此处没有问题,但下面就出现问题了。
FileNode.ImageIndex:=1;
FileNode.SelectedIndex := 2;
UpPath:=FileTable['所属文件夹']+FileTable['文件名称']+'/';
Add(FileNode,UpPath);
FileTable.Next;
End;
End;
End;
begin
With FileDataModule Do
Try
Begin
FileTable.DisableControls;
FileTable.Filtered:=TRUE;
TreeView.Items.Clear;
RootNode := TreeView.Items.Add( nil, 'Favorite' );
RootNode.ImageIndex := 0;
CDTable.Open;
FileTable.Open;
FileCDTable.Open;
CDNOTable.Open;
CDTable.First;
while not CDTable.EOF do
begin
CDName :=CDTable['光盘名称'];
CDNode := TreeView.Items.AddChild( RootNode, CDName );
CDNode.ImageIndex := 1;
CDNode.SelectedIndex := 2;
FileTable.Filter := Format( '光盘名称 = ''%s''', [ CDName ] );
UpPath:='*';
Add(CDNode,UpPath);
CDTable.Next;
end;
FileTable.Filter := '';
FileTable.Filtered:=FALSE;
FileTable.EnableControls;
RootNode.Expand( False );
RootNode.Selected := True;
End;
Finally
FileTable.Close;
CDTable.Close;
End;
end;
procedure TMainForm.TreeViewChange(Sender: TObject; Node: TTreeNode);
var
I : Integer;
ListItem : TListItem;
Path:String;
begin
if (Node.Level=nlRoot) OR (Node.Level=nlCD) then
begin
ListView.Items.BeginUpdate;
try
ListView.Items.Clear;
for I := 0 to Node.Count - 1 do
begin
ListItem := ListView.Items.Add;
ListItem.Caption := Node.Item[ I ].Text;
ListItem.ImageIndex := 1
end;
finally
ListView.Items.EndUpdate;
End;
End
else
Begin
ListView.Items.BeginUpdate;
Try
ListView.Items.Clear;
for I := 0 to Node.Count - 1 do
begin
ListItem := ListView.Items.Add;
ListItem.Caption :=Node.Item[ I ].Text;
ListItem.ImageIndex := 1
end;
// ShowMessage(String(Node.Data));
Path := String(Node.Data);
~~~此处的Path值乱七八糟'#0#.....'不知为什么?
Path :=Path+Node.Text+'/';
With FileDataModule.FileTable Do
Begin
Open;
First;
Filter:=Format('所属文件夹=''%s'' AND 文件类型<>''文件夹''', [Path]);
~~~~
{ 错误:Project Project1.exe raised excption class EDatabaseError with
message 'Unterminated string constant'.Process stopped.Use Step
or Run to continue.
}
While Not Eof Do
Begin
if FieldByName('文件类型').AsString<>'文件夹' then
Begin
ListItem := ListView.Items.Add;
ListItem.Caption := FieldByName('文件名称').AsString;
ListItem.ImageIndex := 3;
End;
FileDataModule.FileTable.Next;
End;
Close;
End;
finally
ListView.Items.EndUpdate;
End;
End;
end;
end.
var
RootNode, CDNode : TTreeNode;
CDName,UpPath : string;
Procedure Add(UpNode:TTreeNode;UpPath:String);
Var
FileNode:TTreeNode;
Path:String;
Begin
With FileDataModule Do
Begin
If UpPath<>'*' Then
FileTable.Filter:=Format('光盘名称=''%s'' AND 所属文件夹=''%s'' AND 文件类型=''文件夹''', [CDName,UpPath]);
FileTable.First;
While Not FileTable.EOF Do
Begin
Path := FileDataModule.FileTable[ '所属文件夹' ] ;
FileNode := TreeView.Items.AddChildObject( UpNode,
FileDataModule.FileTable[ '文件名称' ],
Pointer(Path));
ShowMessage(Path);
ShowMessage(String(FileNode.Data));
~~~~~~~~~~~~~~~~~此处没有问题,但下面就出现问题了。
FileNode.ImageIndex:=1;
FileNode.SelectedIndex := 2;
UpPath:=FileTable['所属文件夹']+FileTable['文件名称']+'/';
Add(FileNode,UpPath);
FileTable.Next;
End;
End;
End;
begin
With FileDataModule Do
Try
Begin
FileTable.DisableControls;
FileTable.Filtered:=TRUE;
TreeView.Items.Clear;
RootNode := TreeView.Items.Add( nil, 'Favorite' );
RootNode.ImageIndex := 0;
CDTable.Open;
FileTable.Open;
FileCDTable.Open;
CDNOTable.Open;
CDTable.First;
while not CDTable.EOF do
begin
CDName :=CDTable['光盘名称'];
CDNode := TreeView.Items.AddChild( RootNode, CDName );
CDNode.ImageIndex := 1;
CDNode.SelectedIndex := 2;
FileTable.Filter := Format( '光盘名称 = ''%s''', [ CDName ] );
UpPath:='*';
Add(CDNode,UpPath);
CDTable.Next;
end;
FileTable.Filter := '';
FileTable.Filtered:=FALSE;
FileTable.EnableControls;
RootNode.Expand( False );
RootNode.Selected := True;
End;
Finally
FileTable.Close;
CDTable.Close;
End;
end;
procedure TMainForm.TreeViewChange(Sender: TObject; Node: TTreeNode);
var
I : Integer;
ListItem : TListItem;
Path:String;
begin
if (Node.Level=nlRoot) OR (Node.Level=nlCD) then
begin
ListView.Items.BeginUpdate;
try
ListView.Items.Clear;
for I := 0 to Node.Count - 1 do
begin
ListItem := ListView.Items.Add;
ListItem.Caption := Node.Item[ I ].Text;
ListItem.ImageIndex := 1
end;
finally
ListView.Items.EndUpdate;
End;
End
else
Begin
ListView.Items.BeginUpdate;
Try
ListView.Items.Clear;
for I := 0 to Node.Count - 1 do
begin
ListItem := ListView.Items.Add;
ListItem.Caption :=Node.Item[ I ].Text;
ListItem.ImageIndex := 1
end;
// ShowMessage(String(Node.Data));
Path := String(Node.Data);
~~~此处的Path值乱七八糟'#0#.....'不知为什么?
Path :=Path+Node.Text+'/';
With FileDataModule.FileTable Do
Begin
Open;
First;
Filter:=Format('所属文件夹=''%s'' AND 文件类型<>''文件夹''', [Path]);
~~~~
{ 错误:Project Project1.exe raised excption class EDatabaseError with
message 'Unterminated string constant'.Process stopped.Use Step
or Run to continue.
}
While Not Eof Do
Begin
if FieldByName('文件类型').AsString<>'文件夹' then
Begin
ListItem := ListView.Items.Add;
ListItem.Caption := FieldByName('文件名称').AsString;
ListItem.ImageIndex := 3;
End;
FileDataModule.FileTable.Next;
End;
Close;
End;
finally
ListView.Items.EndUpdate;
End;
End;
end;
end.