Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "KOL";
Текущий архив: 2009.08.09;
Скачать: [xml.tar.bz2];

Вниз

Сохранение содержимого 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 вся ветка

Форум: "KOL";
Текущий архив: 2009.08.09;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.45 MB
Время: 0.007 c
2-1244623616
QAZ
2009-06-10 12:46
2009.08.09
поиск папок


15-1244189127
scl20
2009-06-05 12:05
2009.08.09
Создание клиент-серверного приложения в Delphi


2-1244902017
Б
2009-06-13 18:06
2009.08.09
Поменять Win-окну размеры.


15-1244233802
Юрий
2009-06-06 00:30
2009.08.09
С днем рождения ! 6 июня 2009 суббота


1-1211807607
Jungle
2008-05-26 17:13
2009.08.09
"Правильно" преобразовать тип Variant





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский