Delphi-PRAXiS
Seite 2 von 2     12   

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi Listbox Leeren (https://www.delphipraxis.net/52613-listbox-leeren.html)

100nF 1. Sep 2005 16:43

Re: Listbox Leeren
 
dann beschreib uns mal, was du geändert hast, damit sich die listboxen leeren lassen. am besten mit code.

JWeis 2. Sep 2005 07:21

Re: Listbox Leeren
 
[i]vorher
Delphi-Quellcode:
function FindAllFiles(RootFolder: string; Mask: string = '*.*'; Recurse: Boolean
  = True): TStinDynA;
var
//--Funktionsvariablen--------------------------------------------------------------------- 
  Wn32FiDa: TWin32FindData;
  File0001: THandle;

begin
  if AnsiLastChar(RootFolder) <> '\' then
  begin
    RootFolder := RootFolder + '\';
  end;
  if Recurse then
  begin{if-1} 
    File0001 := FindFirstFile(PChar(RootFolder + '*.*'), Wn32FiDa);
    if File0001 <> INVALID_HANDLE_VALUE then
    try {try(if-2)} 
      repeat
      if Wn32FiDa.dwFileAttributes and FILE_ATTRIBUTE_DIRECTORY=FILE_ATTRIBUTE_DIRECTORY then
      begin
        if (string(Wn32FiDa.cFileName) <> '.') and (string(Wn32FiDa.cFileName) <> '..')then
        begin
          FindAllFiles(RootFolder + Wn32FiDa.cFileName, Mask, Recurse);
        end;
      end;
      until FindNextFile(File0001, Wn32FiDa) = False;
      finally
      windows.FindClose(File0001);
    end;{try(if-2)} 
  end;{if 1} 
  File0001 := FindFirstFile(PChar(RootFolder + '*.*'), Wn32FiDa);
  if File0001 <> INVALID_HANDLE_VALUE then
  try {try(if-4)} 
    repeat
      if Wn32FiDa.dwFileAttributes and FILE_ATTRIBUTE_DIRECTORY <>
        FILE_ATTRIBUTE_DIRECTORY then
      begin
        gFileCont := length(gFile0001)+1;
        Setlength(gFile0001, gFileCont);
        gFile0001[gFileCont - 1] := RootFolder + String(Wn32FiDa.cFileName);
      end;{if-3} 
    until FindNextFile(File0001, Wn32FiDa) = False;
    finally
    Windows.FindClose(File0001);
  end;{try(if-4)} 
end;{Funktion}
Nachher
Delphi-Quellcode:
function FindAllFiles(RootFolder: string; Mask: string = '*.*'; Recurse: Boolean
  = True): TStinDynA;
var
//--Funktionsvariablen--------------------------------------------------------------------- 
  Wn32FiDa: TWin32FindData;
  File0001: THandle;

begin
  SetLength(gFile0001, 0); //<= das hab ich eingefügt!!
  if AnsiLastChar(RootFolder) <> '\' then
  begin
    RootFolder := RootFolder + '\';
  end;
  if Recurse then
  begin{if-1} 
    File0001 := FindFirstFile(PChar(RootFolder + '*.*'), Wn32FiDa);
    if File0001 <> INVALID_HANDLE_VALUE then
    try {try(if-2)} 
      repeat
      if Wn32FiDa.dwFileAttributes and FILE_ATTRIBUTE_DIRECTORY=FILE_ATTRIBUTE_DIRECTORY then
      begin
        if (string(Wn32FiDa.cFileName) <> '.') and (string(Wn32FiDa.cFileName) <> '..')then
        begin
          FindAllFiles(RootFolder + Wn32FiDa.cFileName, Mask, Recurse);
        end;
      end;
      until FindNextFile(File0001, Wn32FiDa) = False;
      finally
      windows.FindClose(File0001);
    end;{try(if-2)} 
  end;{if 1} 
  File0001 := FindFirstFile(PChar(RootFolder + '*.*'), Wn32FiDa);
  if File0001 <> INVALID_HANDLE_VALUE then
  try {try(if-4)} 
    repeat
      if Wn32FiDa.dwFileAttributes and FILE_ATTRIBUTE_DIRECTORY <>
        FILE_ATTRIBUTE_DIRECTORY then
      begin
        gFileCont := length(gFile0001)+1;
        Setlength(gFile0001, gFileCont);
        gFile0001[gFileCont - 1] := RootFolder + String(Wn32FiDa.cFileName);
      end;{if-3} 
    until FindNextFile(File0001, Wn32FiDa) = False;
    finally
    Windows.FindClose(File0001);
  end;{try(if-4)} 
end;{Funktion}

JWeis 2. Sep 2005 07:36

Re: Listbox Leeren
 
:oops: ich bin so blöd!! :wall: :wall:
Ich habs falsch eingefügt.


jetzt get's

habs jetzt
Delphi-Quellcode:
procedure TForm1.Btncopy0004Click(Sender: TObject);
begin
  SetLength(gFile0001, 0); //<= Hier ausprobiert!! 
  LbxCopy0001.Items.clear;      
  LBxCopy0002.Items.clear;    
  EdtCopy0001.Text:='';
end;
und auf anhieb klapt's ohne Probleme


Alle Zeitangaben in WEZ +1. Es ist jetzt 09:31 Uhr.
Seite 2 von 2     12   

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz