 
			
				16.10.2023, 21:35
			
			
			
		  
	 | 
	
		
		
		
			
			| 
			
				
				
				 Новичок 
				
				
			 | 
			  | 
			
				
				
					Регистрация: 18.03.2009 
					
					
					Сообщения: 82
 
				
					Репутация: 10 
					    
				 
				
			 | 
		 
		 
		
	 | 
	
	
	
		
			
			
				 
				сократил код
			 
			 
			
		
		
		
		
	Код: 
	type
  TFileItemData = class
    AFileName : String;
    ASize : String;
    function toString : String;
  end;
function TFileItemData.toString : String;
begin
  Result := Format('Value1: %s; Value2: %d',[AFileName,ASize]);
end;
procedure TForm1.AddToMemoCb(AFileName:String;ASize:integer);
begin
listbox1.Items.Add(Format('Filename: %s; Size: %d',[AFileName,ASize]));
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
FileImg('G:\leon\delphis\delphi64\sql2\06\Win32\Debug\db\',AddToMemoCb);
end;
procedure TForm1.FileImg(const dirName:string; ACallBack : TInsertImageToDbCallBack);
var
  searchResult: TSearchRec;
begin
  if FindFirst(dirName+'\*', faAnyFile, searchResult)=0 then begin
    try
      repeat
        if (searchResult.Attr and faDirectory)=0 then begin
          if SameText(ExtractFileExt(searchResult.Name), '.jpg') then
            ACallBack(IncludeTrailingBackSlash(dirName)+searchResult.Name,searchResult.Size);
        end else if (searchResult.Name<>'.') and (searchResult.Name<>'..') then begin
         FileImg(IncludeTrailingBackSlash(dirName)+searchResult.Name,AddToMemoCb);
         end;
      until FindNext(searchResult)<>0
    finally
      FindClose(searchResult);
    end;
  end;
end;
procedure TForm1.FormDestroy(Sender: TObject);
var
  I : Integer;
  obj : TFileItemData;
begin
  for I := 0 to ListBox1.Items.Count-1 do
    begin
      obj := ListBox1.Items.Objects[i] As TFileItemData;
      obj.Free;
    end;
end;
procedure TForm1.ListBox1Click(Sender: TObject);
var
  obj : TFileItemData;
begin
  if ListBox1.ItemIndex > -1 then
    begin
      obj := ListBox1.Items.Objects[ListBox1.ItemIndex] As TFileItemData;
      ShowMessage(obj.toString);
    end;
end; 
 
111.jpg
когда делаешь с LISTBOX2 (уже заполненным ) = проблем нет. НО в listbox1 значение берутся с поиска, и здесь глюк  
		
	
		
		
			
			
			
		
			
			
			
			
			
			
			
			
			 
		
		
		
		
		
		
	
		
			
			
			
			
				 
			
			
			
			
		 
		
	
	
	 |