Autor Beitrag
D. Annies
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Di 05.02.13 22:26 
Hi, Delpher,

meine FileListbox zeigt, wenn ich das Verzeichnis wechsele, die Dateien doppelt an,
obwohl sie nur einfach vorhanden sind.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
procedure TBuchMain.DriveComboBox1Change(Sender: TObject);
begin
  DirectoryListBox1.Drive := DriveComboBox1.Drive;
  FileListBox1.Drive := DirectoryListBox1.Drive;
  Filelistbox1.Directory := DirectoryListbox1.Directory;
end;

procedure TBuchMain.DirectoryListBox1Change(Sender: TObject);
begin
  FileListbox1.Clear;  // hatte gedacht, das hilft, aber nein
  FileListBox1.Directory := DirectoryListBox1.Directory;
  label30.Caption := FileListbox1.Directory;
  if label30.Caption[length(label30.Caption)] <> '\' then label30.Caption := label30.Caption + '\';
end;


Was ist da falsch?

Danke für Hinweise,
Detlef

_________________
ut vires desint, tamen est laudanda voluntas
WasWeißDennIch
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 653
Erhaltene Danke: 160



BeitragVerfasst: Mi 06.02.13 09:08 
Abgesehen davon, dass die Komponenten eigentlich veraltet sind (sie stehen ja nicht umsonst auf dem Reiter Win 3.1): wieso machst Du denn alles per Code? Der DriveComboBox kannst Du als DirList die DirectoryListbox zuweisen, der wiederum als DirLabel das Label30 (die Benennung solltest Du vielleicht überdenken) und als FileList die FileListbox. Der Rest geschieht dann automatisch.

Für diesen Beitrag haben gedankt: D. Annies
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Mi 06.02.13 15:56 
Danke für deine Mühe, das probiere ich gleich mal aus!
Gruß, Detlef

_________________
ut vires desint, tamen est laudanda voluntas
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Mi 03.04.13 09:09 
Moin,

jetzt im Urlaub habe ich mal etwas genauer hingesehen. Es werden nur die .dbf-Dateien in der Filelistbox doppelt
angezeigt, alle anderen sind einmal zu sehen, so wie es sein soll.
Ich habe die Komponenten Directorylistbox und Filelistbox auch brav per OI verbunden, trotzdem dieser Fehler.
Gibt es dazu noch eine Idee?

Gruß, Detlef

_________________
ut vires desint, tamen est laudanda voluntas
Frühlingsrolle
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Mi 03.04.13 15:47 
- Nachträglich durch die Entwickler-Ecke gelöscht -
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Mi 03.04.13 17:29 
Moin, Frühlingsrolle,

danke für deine Mühe!
Nun, die Zuweisungen sind alle drei korrekt.

Uff, sagt Detlef

_________________
ut vires desint, tamen est laudanda voluntas
WasWeißDennIch
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 653
Erhaltene Danke: 160



BeitragVerfasst: Mi 03.04.13 18:45 
Und Du bist sicher, dass die Dateien doppelt angezeigt werden, aber nicht "doppelt" vorhanden sind (Kopie mit Leerzeichen im Namen oder solche Spässkes)?
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Mi 03.04.13 20:23 
Ja, da bin ich mir sicher.
Gruß, Detlef

_________________
ut vires desint, tamen est laudanda voluntas
WasWeißDennIch
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 653
Erhaltene Danke: 160



BeitragVerfasst: Mi 03.04.13 20:47 
Pack doch mal eine einfache ListBox auf Dein Formular und probier das hier aus:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
procedure ListFilesInListBox(Path: string; ListBox: TListBox);
const
  ALL_FILEATRRIBUTES = DDL_READWRITE or DDL_ARCHIVE or DDL_HIDDEN or DDL_READONLY or DDL_SYSTEM; 
begin
  Path := IncludeTrailingPathDelimiter(Path) + '*';
  SendMessage(ListBox.Handle, LB_DIR, ALL_FILEATRRIBUTES, lParam(PChar(Path)));
end;

//Beispielaufruf:
procedure TForm1.Button1Click(Sender: TObject);
begin
  ListFilesInListBox(DirectoryListbox1.Directory, ListBox1);
end;

Sid die Dateien dann auch doppelt in der "normalen" Listbox vorhanden?
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Do 04.04.13 11:05 
Moin,
also, die Directorylistbox zeigt an, aber die Listbox ist leer.
LG, Detlef

_________________
ut vires desint, tamen est laudanda voluntas
WasWeißDennIch
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 653
Erhaltene Danke: 160



BeitragVerfasst: Do 04.04.13 13:31 
Leer? Das kann ich nicht nachvollziehen, ich habe hier einmal eine DriveComboBox, eine DirectoryListBox, eine FileListBox, einen Button und eine ListBox auf mein Formular (Delphi 7) gezogen. Im ButtonClick steht der gepostete Code. Einzige Änderung, die ich gemacht habe: in ListFilesInListBox als erste Zeile ein "ListBox.Clear" eingefügt. Im Ergebnis zeigt die ListBox ggf. mehr Dateien an als die FileListBox, vermutlich wegen der Dateiattribute.
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Do 04.04.13 16:00 
Das ist ja mehr als merkwürdig! Ich habe jetzt auch mal das Listbox1.clear dazu gesetzt,
aber keine Änderung, sie bleibt leer. Die DriveCombobox funzt.
:-(
LG, Detlef

_________________
ut vires desint, tamen est laudanda voluntas
WasWeißDennIch
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 653
Erhaltene Danke: 160



BeitragVerfasst: Do 04.04.13 17:46 
Funktioniert das Projekt im Anhang?
Einloggen, um Attachments anzusehen!

Für diesen Beitrag haben gedankt: D. Annies
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Do 04.04.13 17:59 
Entschuldige hoch 3!!!

Ich hatte vergessen, auf den Button zu drücken... :oops: :oops: :oops:
Es wird alles richtig angezeigt.

Danke für deine Geduld und Zähigkeit!

LG, Detlef

Jetzt geht es für mich darum, den Button zu vermeiden.

_________________
ut vires desint, tamen est laudanda voluntas
WasWeißDennIch
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 653
Erhaltene Danke: 160



BeitragVerfasst: Do 04.04.13 18:04 
user profile iconD. Annies hat folgendes geschrieben Zum zitierten Posting springen:
Jetzt geht es für mich darum, den Button zu vermeiden.

Siehe das hochgeladene Projekt ;)

Für diesen Beitrag haben gedankt: D. Annies
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Do 04.04.13 18:14 
Ich hab's - ohne deine Idee anzusehen, - es nach OnShow des Formulars gelegt. :D
LG, Detlef

_________________
ut vires desint, tamen est laudanda voluntas
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Do 04.04.13 21:38 
Na, ja, es musste nach OnCreate(); :D
Alles i.O.
LG, Detlef, Danke

_________________
ut vires desint, tamen est laudanda voluntas
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Mi 10.04.13 18:17 
Habe gerade ein dickes Brett vor dem Kopf:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
procedure TBuchMain.ListFilesInListBox(Path: string; ListBox: TListBox);
const
  ALL_FILEATRRIBUTES = DDL_READWRITE or DDL_ARCHIVE or DDL_HIDDEN or DDL_READONLY or DDL_SYSTEM;
begin
  Path := IncludeTrailingPathDelimiter(Path) + '*.dbf';
  SendMessage(ListBox.Handle, LB_DIR, ALL_FILEATRRIBUTES, lParam(PChar(Path)));
end;

procedure TBuchMain.Filterdbf1Click(Sender: TObject);
begin
  listbox8.clear;
  ListFilesInListBox(DirectoryListbox1.Directory, ListBox8);
end;

procedure TBuchMain.AlleDateien1Click(Sender: TObject);
begin
  listbox8.Clear;
  ListFilesInListBox(DirectoryListbox1.Directory, ListBox8);
end;


Wie kriege ich es am einfachsten hin, dass ich mit dem Popup-Menü mit den beiden Einträgen
Filterdbf1click() und AlleDateien1click() den entsprechenden Filter *.dbf bzw. *.*
übergeben kann?

Danke, Detlef

_________________
ut vires desint, tamen est laudanda voluntas
WasWeißDennIch
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 653
Erhaltene Danke: 160



BeitragVerfasst: Mi 10.04.13 18:40 
Wie wäre es mit einem weiteren Parameter für die Dateimaske?
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
procedure TBuchMain.ListFilesInListBox(Path: string; ListBox: TListBox; const Filemask: string = '*');
const
  ALL_FILEATRRIBUTES = DDL_READWRITE or DDL_ARCHIVE or DDL_HIDDEN or DDL_READONLY or DDL_SYSTEM;
begin
  ListBox.Clear;
  Path := IncludeTrailingPathDelimiter(Path) + Filemask;
  SendMessage(ListBox.Handle, LB_DIR, ALL_FILEATRRIBUTES, lParam(PChar(Path)));
end;

procedure TBuchMain.Filterdbf1Click(Sender: TObject);
begin
  ListFilesInListBox(DirectoryListbox1.Directory, ListBox8, '*.dbf');
end;

procedure TBuchMain.AlleDateien1Click(Sender: TObject);
begin
  ListFilesInListBox(DirectoryListbox1.Directory, ListBox8);
end;

Für diesen Beitrag haben gedankt: D. Annies
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Mi 10.04.13 20:08 
Danke dir, hatte ich mir so auch schon gedacht.
Neu für mich ist die Idee mit const.
Na, denn mache ich mich mal an die Arbeit. ...
LG, Detlef

Klappt hervorragend ! :-))

_________________
ut vires desint, tamen est laudanda voluntas