Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2009.08.09;
Скачать: CL | DM;

Вниз

Сохранение содержимого TreeView   Найти похожие ветки 

 
ILPU   (2008-03-07 08:24) [0]

Как сохранить содержимое TreeView в файл и
обратно загрузить?


 
Dimaxx ©   (2008-03-07 10:35) [1]

Никак. Писать самому сохранение...


 
ILPU ©   (2008-03-11 17:27) [2]

Можно использовать For i := 1 to MYTreeView.Count do begin а вот как дальше?
Идеи есть у кого?


 
ILPU ©   (2008-03-11 17:27) [3]

Можно использовать For i := 1 to MYTreeView.Count do begin а вот как дальше?
Идеи есть у кого?


 
Дмитрий К ©   (2008-03-11 17:52) [4]

Цитата:

Slay  (24.01.05 11:28)  [8]

Вот пример сохранения и загрузки данных TreeView. У меня работает.

//Сохранение TreeView в файл (Base.dat)

function Save2File(Sender:TKOLTreeView): Boolean;
var
F: HFile;

procedure item2file(ind:cardinal);
var
len:cardinal;
path: String;
begin
while ind<>0 do
begin
 path := sender.TVItemPath(ind,"\");
 len :=length(path) ;
 FileWrite( F, len,4);
 FileWrite( F, path[1], len );
 if Sender.TVItemChild[ind]<>0 then item2file(Sender.TVItemChild[ind]);
 ind := sender.TVItemNext[ind];
end;
end;

begin
result := false;
F := FileCreate("Base.dat", ofOpenWrite or ofCreateAlways);// or ofShareExclusive ofShareDenyRead or ofShareDenyWrite
if F = INVALID_HANDLE_VALUE then Exit;

item2file(Sender.TVRoot);

FileClose( F );
result := true;
end;

//Загрузка из файла(Base.dat) в TreeView

function LoadFromFile(Sender:TKOLTreeView): Boolean;
var
 len,ind : cardinal;
 F : HFile;
 Path: String;

function IndPath:cardinal;
var
 tmpPath,tmpText: String;
begin
tmpPath := ExtractFilePath(Path);
result := Sender.TVRoot;
tmpText := parse(tmpPath,"\");
while result<>0 do
if sender.TVItemText[result] = tmpText then
begin
 if length(tmpPath)=0 then exit;
 result:= sender.TVItemChild[result];
 tmpText := parse(tmpPath,"\");
end else result:= sender.TVItemNext[result];
end;

begin
result := false;
F := FileCreate("Base.dat", ofOpenRead or ofOpenExisting);//  or ofShareExclusive
if F = INVALID_HANDLE_VALUE then Exit;
Sender.BeginUpdate;
while FileRead(F,len,4)<>c0 do
begin
 SetLength(Path,len);
 FileRead(F,Path[1],len);
 ind := IndPath;
 Sender.TVInsert(ind,TVI_SORT,ExtractFileName(path))
end;
Sender.EndUpdate;
FileClose( F );
result := true;
end;

Конец цитаты.


 
ILPU ©   (2008-03-12 08:58) [5]

Большое спасибо!



Страницы: 1 вся ветка

Текущий архив: 2009.08.09;
Скачать: CL | DM;

Наверх




Память: 0.48 MB
Время: 0.011 c
8-1196371243
leonidus
2007-11-30 00:20
2009.08.09
Как отобразить одну картинку на другой?


2-1243941065
Franzy
2009-06-02 15:11
2009.08.09
В Delphi точно нет конструктора массивов?


8-1196172352
DeadMeat
2007-11-27 17:05
2009.08.09
Щелчки при воспроизведении звука


2-1244704948
lewka
2009-06-11 11:22
2009.08.09
Математика в Delphi


15-1244308171
oldman
2009-06-06 21:09
2009.08.09
Прикрутить значек к сайту в "Избранное"