Autor Beitrag
DelphiNoob
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 152

Win 2003 Server
D7 Ent
BeitragVerfasst: So 09.02.03 18:21 
Hi,

ich übe gerade ein bissel was mit ListViews, und habe mir mal folgenden Code dafür zu nutze gemacht:

home.pages.at/dbr-so.../delphi/einlesen.htm

Ich habe nun ein Verzeichnis das mir angezeigt wird im ListView mit ein paar Verknüpfungen darin.

Ich möchte nun, das wenn ich im Explorer eine Verknüpfung "verstecke", das sie beim Ausführen meiner Anwendung auch nicht angezeigt wird.

Nur leider hab ich keine Ahnung wie ich das anstelle. Hab mir mal ein paar tutorials zum thema attribute setzen angesehen, nur half mir das nicht weiter. Irgendwie habe ich es immer nur geschafft, das keine ordner angezeigt werden.

Hoffe auf Hilfe.

Mfg
DelphiNoob


Zuletzt bearbeitet von DelphiNoob am So 09.02.03 21:00, insgesamt 1-mal bearbeitet
Wolff68
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 302
Erhaltene Danke: 1

WinXP home
D6 Prof
BeitragVerfasst: So 09.02.03 20:03 
Im ObjectInspector kannst Du unter ObjectTypes otHidden ein- und ausschalten.

Im Code geht es zB damit:
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
procedure TForm1.Button1Click(Sender: TObject);
begin
 IF otHidden in ShellListView1.ObjectTypes then
   ShellListView1.ObjectTypes := [otFolders, otNonFolders]
 else
   ShellListView1.ObjectTypes := [otFolders, otNonFolders, otHidden];
end;

_________________
"Der Mensch ist nicht was er sich vorstellt oder wünscht zu sein, sondern das was andere in ihm sehen."
DelphiNoob Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 152

Win 2003 Server
D7 Ent
BeitragVerfasst: So 09.02.03 20:05 
Danke, werd ich gleich testen.

Nur als kleiner Anhang, hab den obigen verlinkten Code für meine Wünschte ziemlich kastriert. Aber mehr brauch ich nicht :)

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
if h<>INVALID_HANDLE_VALUE then repeat
if sr.dwFileAttributes and FILE_ATTRIBUTE_DIRECTORY = 0 then begin
listitem:=lv.items.add;
listitem.caption:=sr.cFilename;
SHGetFileInfo(pchar(pfad+sr.cFileName),0,FileInfo,gr,SHGFI_TypeName or SHGFI_ICON);
Icon.handle:=FileInfo.hIcon;
listitem.Imageindex:=il.addIcon(Icon);
end;
until Findnextfile(h,sr)=false;
Icon.free;
hlp.free;
lv.items.endupdate;
end;
DelphiNoob Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 152

Win 2003 Server
D7 Ent
BeitragVerfasst: So 09.02.03 20:10 
Delphi scheint nicht ganz klar zu sein, was er mit ObjectTypes anfangen soll. Des weiteren hab ich im Objektinspektor auch nicht diese Option. Tut mir leid.

[Fehler] Unit1.pas(78): Undefinierter Bezeichner: 'ObjectTypes'
[Fehler] Unit1.pas(78): Undefinierter Bezeichner: 'otFolders'
[Fehler] Unit1.pas(78): Undefinierter Bezeichner: 'otNonFolders'
[Fehler] Unit1.pas(78): Undefinierter Bezeichner: 'otHidden'
DelphiNoob Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 152

Win 2003 Server
D7 Ent
BeitragVerfasst: So 09.02.03 20:43 
So, alle Probleme gelöst, so sieht der endgültige Code aus:

ausblenden volle Höhe Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
procedure einlesen(pfad:string);
var
sr:TWin32FindData;
h:THandle;
listitem:TListitem;
FileInfo:SHFileInfo;
gr:integer;
Icon:TIcon;
hlp:TListview;
begin
il.clear;
lv.items.clear;
hlp:=TLIstview.create(nil);
hlp.visible:=false;
hlp.parent:=lv;
hlp.sorttype:=sttext;
Icon:=TIcon.Create;
gr:=sizeof(FileInfo);
lv.items.beginupdate;
h:=FindFirstFile(PChar(pfad+'*.*'),sr);

if h<>INVALID_HANDLE_VALUE then repeat
if sr.dwFileAttributes and FILE_ATTRIBUTE_HIDDEN = 0 then
if sr.dwFileAttributes and FILE_ATTRIBUTE_DIRECTORY = 0 then begin
listitem:=lv.items.add;
listitem.caption:=sr.cFilename;
SHGetFileInfo(pchar(pfad+sr.cFileName),0,FileInfo,gr,SHGFI_TypeName or SHGFI_ICON);
Icon.handle:=FileInfo.hIcon;
listitem.Imageindex:=il.addIcon(Icon);
end;
until Findnextfile(h,sr)=false;
Icon.free;
hlp.free;
lv.items.endupdate;
end;
DelphiNoob Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 152

Win 2003 Server
D7 Ent
BeitragVerfasst: Mo 10.02.03 15:33 
Neuer Tag, neues Problem, neue Frage, ALTER Thread *g*

Wir schreiben immer noch das gleiche ListView nach Christus wie oben...

Spontan viel mir heute ein, das ich die Items bzw Icons ja bei Doppelklick auch öffnen will. Insbesondere Verknüpfungen. Leider hab ich absolut keinen schimmer.

Grob kann ich mir das ausmalen: Bei Doppelklick in die Listview soll er ne Abfrage starten ob ein Icon / Item angeklickt wurde, wenn das zutrifft dann öffne das angeklickte Item.

Nur wie umsetzen? Hat jemand nen Denkanstoß?

Mfg
Delphi Noob
maximus
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 896

Win XP, Suse 8.1
Delphi 4/7/8 alles prof
BeitragVerfasst: Mo 10.02.03 15:40 
da gibt es ein event das OnDblClick heist. Da drin kannste die nötige abfrage machen und dann das ausgewählte item öffnen!

mfg mäximus
DelphiNoob Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 152

Win 2003 Server
D7 Ent
BeitragVerfasst: Mo 10.02.03 15:44 
Achne *g*

Soviel wissen hab ich auch! Nur was soll ins Event rein... da liegt ja mein Problem! Weil soviel Fachwissen habe ich (noch) nicht.

Aller Anfang ist schwer!
DelphiNoob Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 152

Win 2003 Server
D7 Ent
BeitragVerfasst: Mo 10.02.03 17:28 
Hab mir das nun ein bissel angeschaut, aber eine wirkliche Lösung ist noch nicht in sicht.

Hab erstmal versucht bissel was raus zu bekommen:

ausblenden Quelltext
1:
2:
3:
4:
procedure TForm1.ListView1DblClick(Sender: TObject);
begin
MessageDlg(ListView1.ItemFocused.Caption, mtInformation, [mbOk], 0);
end;


So weiß ich wenigstens schon mal das ItemFocused das Item ist was ich anklicke bzw was durch den ersten Klick makiert ist.
Ein Problem ist allerdings, das wenn ein Item makiert ist, und ich irgendwo in das Bild klicke dennoch die Message Box erscheint.

Ich müsste also irgendwie abfragen ob beim Klick die Maus direkt auf dem Icon / Item ist! Nur wie????

Und dann wäre da ja noch das "öffnen" des Programmes was sich hinter den Verknüpfungen verbirgt. Vieleicht mit CreateProcess? *sich nicht sicher ist*

Hoffe auf Antwort.
DelphiNoob Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 152

Win 2003 Server
D7 Ent
BeitragVerfasst: Mo 10.02.03 23:11 
Niemand ne idee? Ich meine das muss irgendwie gehen... ich hab nur echt kein Plan!
Tino
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Veteran
Beiträge: 9839
Erhaltene Danke: 45

Windows 8.1
Delphi XE4
BeitragVerfasst: Di 11.02.03 00:09 
DelphiNoob hat folgendes geschrieben:
Ich müsste also irgendwie abfragen ob beim Klick die Maus direkt auf dem Icon / Item ist! Nur wie????

Schau Dir mal die Funktion GetHitTestInfoAt der tListView an. Diese liefert Dir Information wo genau die Maus sich aus Sicht der ListView befindet!

Gruß
TINO
DelphiNoob Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 152

Win 2003 Server
D7 Ent
BeitragVerfasst: Di 11.02.03 10:16 
Danke, werd ich machen!

(Auf den Funktionsnamen muss man erstmal kommen, der hört sich garnicht danach an!)
Tino
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Veteran
Beiträge: 9839
Erhaltene Danke: 45

Windows 8.1
Delphi XE4
BeitragVerfasst: Di 11.02.03 10:59 
DelphiNoob hat folgendes geschrieben:
Auf den Funktionsnamen muss man erstmal kommen, der hört sich garnicht danach an!

In Zukunft einfach immer in der Hilfe die Eigenschaften, Methoden und Ereignisse der entsprechenden Komponenten durchgehen und lesen!

Gruß
TINO
DelphiNoob Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 152

Win 2003 Server
D7 Ent
BeitragVerfasst: Di 11.02.03 13:27 
Super. Hat funktioniert!

Kann man eine Verknüpfung auch einfach per CreateProcess öffnen?

EDIT:

Ok, nein, kann man nicht mit create process öffnen. Nur wie dann?!