Solved

Need a Delphi component to list files in various folders

Posted on 2008-06-25
23
2,062 Views
Last Modified: 2013-11-23
Hi, I'm a Delphi developer and I can't find the right component for this problem. I've searched thru the net - there are thousands of filelist descendants that display files from a SPECIFIC folder, and can be attached to a treeview or something.  Bu no, what I need is a different thing.

I'm developing a file finder app.  I'd like to display search results from different folders, sometimes even different drives, with not just their name but the containing folder attached as a column.  I'm struggling to make it with a grid right now, but it's bad and difficult.  I'm sure there ARE controls that can help me but I can't find them.

So what I need is a control that:
- holds items inserted one by one (not like "all stuff from a folder")
- supports multiple folders, displaying the path for each item,
- supports the standard windows right-clicking context menu (not a simulated one).

Is there such a thing?
Sharewares are okay, I'd be happy to pay for the proper one.
Please tell me if there is a thing that matches all criteria above.
Thanks in advance.
0
Comment
Question by:dkellner
  • 9
  • 5
  • 5
  • +3
23 Comments
 
LVL 14

Expert Comment

by:SteveBay
ID: 21869403
Virtual TreeView might be what you are looking for. It's not exactly "fall-off-your-chair" simple to use but it is amazingly powerful and flexible.
http://www.soft-gems.net/index.php?option=com_content&task=view&id=12&Itemid=33
0
 
LVL 18

Expert Comment

by:Johnjces
ID: 21869812
I am a bit confused, (what else is new)?

Is what you are seeking a full listing of file/folder one after the other? DO you want it in a treeview or just a listing?

"holds items inserted one by one?" Huh?

Check out the screen shot at http://www.jcitssystems.com/FileSearch.htm and/or download the app and see if that is sort of the look you are after.

John
0
 
LVL 3

Author Comment

by:dkellner
ID: 21870549
Maybe I didn't express myself perfectly right. (English is not my mother tongue, sorry for that)

So let's put it this way: I'd like to make a file list.  Imagine a standard Windows file find operation.  The result list will be full of files, found in various folders.  No tree view, no nothing, just the list of files.  I try to attach a picture here, not sure if it works.



image1.png
0
 
LVL 14

Expert Comment

by:SteveBay
ID: 21870582
So what is wrong with using a TListView in Report mode? That is basicly what it is designed to.
0
 
LVL 14

Expert Comment

by:SteveBay
ID: 21870642
Here is a quick example of using TListView to do what you have above
procedure TForm1.FormShow(Sender: TObject);

var     Column : TListColumn;

begin

     ListView1.ViewStyle := vsReport;

     Column := ListView1.Columns.Add;

     Column.Caption := 'Name';

     Column.Width := 100;

     Column := ListView1.Columns.Add;

     Column.Caption := 'In Folder';

     Column.Width := 200;

     Column := ListView1.Columns.Add;

     Column.Caption := 'Size';

     Column.Width := 100;

end;
 

procedure TForm1.Button1Click(Sender: TObject);

var sr : TsearchRec;

     n : Integer;

     Item : TListItem;

begin

     n := FindFirst('C:\Documents and Settings\*.*', faAnyFile,sr);

     While n = 0 do

          begin

          Item := ListView1.Items.Add;

          Item.Caption := sr.Name;

          Item.SubItems.Add( 'C:\Documents and Settings' );

          Item.SubItems.Add( IntToStr(sr.Size) );

          n := FindNext(sr);

          end;

end;

Open in new window

0
 
LVL 3

Author Comment

by:dkellner
ID: 21871348
Thanks SteveBay, but as far as I can see, this is only the "look" of the whole thing. I need to find a VCL component that can:

1. List the files,
2. Really handle them as files.

Your solution only puts strings to a listbox but they will not really be files, or even references to files, they won't have all the assigned functionality, like showing up the file-specific context menu on right click.  FileListBox-like controls can do that - but usually handle a single folder only.

What I need is the combination of these two.
A list, displaying file objects, but from many folders. So that it could be used for a file finder result list.

And again: what I need is a component that surely exists somewhere - so don't bother to write one, not for EE points anyway :) I'm asking if someone has seen such a thing, such a component, such a kind of filelistbox, that's capable of all the above.

Is this still confusing?
I'm trying to explain it properly but tell me if there are missing points.
0
 
LVL 3

Author Comment

by:dkellner
ID: 21871420
To be exact: there is a component named "ShellListView", in the standard D7 component bar, under "Samples" tab. There you can see real files if you specify a directory to view.  The same thing is my dream - but instead of all files from just one folder, I'd like to feed it with certain files from certain folders because this is how a Finder works. Finds any file anywhere - and list them as one result set.

Total Commander, for example, has a function called "feed to listbox" when you're searching for files. It's similar to what I'm looking for.  It lists a "virtual folder", containing only what's found during the search. From anywhere. And with all the functionality of them as files.
0
 
LVL 14

Expert Comment

by:SteveBay
ID: 21871431
No problem. This is part of the process of getting expert advice. Now that you have explained it with a little more clarity perhaps someone will suggest something.
I am afraid that I am not aware of any components that do what you wish. I have no doubt though, that such a component could be written.
0
 
LVL 3

Author Comment

by:dkellner
ID: 21871457
Thanks, Steve.  (and yes, it could be written - but I've suffered enough with a product called DK Finder that tries to implement everything in a grid and now I'm trying to find a professional solution.)
0
 
LVL 36

Expert Comment

by:Geert Gruwez
ID: 21872125
What you see in the Windows Explorer is actually just a list view (set of strings)
with a right click menu attached to it.
The code behind the popupmenu and the shortcut keys is what does all the work to make it look like the strings are files.
Let's put it simple, you can have 1 file in to different location, eg on your harddrive and in the listviews
But you can have a representation (string) of the file in many different locations (or listviews)
Basically what you need is a listview with the code for the popup and the keys.
Just figure out how the registry works and you can write the popup yourself ...
All the configuration for the popupmenu and the shortcut keys is in there
0
 
LVL 36

Expert Comment

by:Geert Gruwez
ID: 21872129
um slight misphrasing ...
you can't have 1 file in multiple locations ,
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 3

Author Comment

by:dkellner
ID: 21872841
Thanks Geert, but it's not that simple.
I've tried to make up the context menu myself and it's very far away from just looking into the registry and fetching a few keys. (As far as I know, of course.)  Maybe there is something I don't know that makes it that simple but ...... well, I spent a few weeks with this and couldn't even find a fair shell context menu component that does the job.

You are right: if I have the listview described above PLUS the shell rightclick thing, then I have something like what I'm looking for. But I've tried a lot and I was not able to implement this.  And I'm sure that if you tried to do it you'd be at least surprised, too. I have logged all registry operations while right clicking on files, I have searched the whole web, etc - now I'm here :)
0
 
LVL 36

Expert Comment

by:Geert Gruwez
ID: 21873087
I didn't know you could log "reading the registry ?"

And yes, now and then I try and find out how things work in the registry.
Alas my brain is not allways as "transparant" as the Microsoft ones ...

maybe one of the things windows explorer is slow is because of the "transparancy" of how it's all set up in the registry.
maybe we should send this remark to Microsoft hehe

as a pro solution i tend to use the
http://www.devexpress.com
components

not simple to get it to work, but once you do ...
0
 
LVL 36

Expert Comment

by:Geert Gruwez
ID: 21873109
just something i wondered ...
the recent file list is actually a list of shortcuts to files

maybe create a searchfolder
open a shellfolder to that searchfolder
for each folder/file you find that answer the search spec create a shortcut in that searchfolder
voila your list with the options you want (but not completely exactly)


0
 
LVL 3

Author Comment

by:dkellner
ID: 21873300
Geert, I've tried this shortcut-tempfolder way (among others) but there is a catch. The standard Explorer functionality includes things like copy, rename, delete - now if you delete the temp shortcut, the actual file will still be there.  If you rename it, the actual file remain the same.  Copying works like "copy shortcut" which is not what user expects.  Moving also seems a "copy shortcut", which is even more confusing.  So this is not the right way - as you said, it's "not completely exactly" the same thing as having a file list.
0
 
LVL 4

Expert Comment

by:spk2000ar
ID: 21880648
Try this code... is a function that returns in a TStringList the files listed in some folder matching some mask.
function ListFiles(Folder, Mask: string; InUpperCase: boolean; var slFileList: TStringList; Ordered: boolean = TRUE): boolean;

var b: boolean; F: TSearchRec; s: string;

begin

  Result := FALSE;

  if Folder = CadenaVacia then

    Exit;

  if not DirectoryExists(Folder) then

    Exit;

  b := TRUE;

  slFileList.Clear;

  if FindFirst(IncludeTrailingPathDelimiter(Folder) + Mask, faAnyFile-faDirectory, F) = 0 then

    begin

      repeat

        s := IncludeTrailingPathDelimiter(Folder) + F.Name;

        if InUpperCase then

          s := Uppercase(s)

        else

          s := Lowercase(s);

        slFileList.Append(s);

      until FindNext(F) <> 0;

      SysUtils.FindClose(F);

    end;

  if Ordered then

    slFileList.Sort;

  Result := b;

end;

Open in new window

0
 
LVL 36

Expert Comment

by:Geert Gruwez
ID: 21881198
Hey don't forget the drag and drop features ...
0
 
LVL 3

Author Comment

by:dkellner
ID: 21894212
Thank you spk but this is absolutely not what I'm looking for.
0
 
LVL 9

Expert Comment

by:alkisg
ID: 21912206
dkellner, just some hints:

There are 2 ways to do this.
1. Use a standard ShellListView.
In this case, you'd make a new virtual folder and add it to the shell namespace, like "My Computer" or "Control Panel". You could e.g. call it "Productname search results" and put it under "My Computer". The user would actually be able to see it in Explorer (and in your application's shelllistview of course) and interact with it.
Info for this:
http://www.whirlingdervishes.com/nselib/  <== I think this is your best bet
http://www.shellplus.com/examples/namespace-extension-example.html
http://www.codebot.org/delphi/?doc=9418

2. Use a custom treeview.
In this case you'd use your own control, list whatever you want there and ask the shell about which operations (menu, drag'n'dropping etc) are permitted for each object. No need for registry reading, there are COM interfaces that give you all the necessary info, but COM programming can be scary at first. This is the way most file managers do it, but I don't know of any component for this.
More info:
http://www.jam-software.com/delphi/shellbrowser.shtml (the invisible TShellBrowser component will give you the info you'll need)
To get an idea of the code needed to query the shell for menus etc:
http://blogs.msdn.com/oldnewthing/archive/2004/09/22/232836.aspx
http://msdn.microsoft.com/en-us/library/bb776094(VS.85).aspx
0
 
LVL 9

Accepted Solution

by:
alkisg earned 500 total points
ID: 21912248
Ehm, they also have a component that I think does exactly what you want:
http://www.jam-software.com/delphi/sb_components.shtml
TJamFileList component! :)
0
 
LVL 14

Expert Comment

by:SteveBay
ID: 21913059
I should have thought of this before. Raize components has Shell Components that work pretty much as you described what you are looking for. Particularly the drag and drop and context menus. http://www.raize.com/DevTools/RzComps/Default.asp
0
 
LVL 3

Author Closing Comment

by:dkellner
ID: 31470732
Exactly, thank you! I've been looking for THIS one. Maybe I've even seen it somewhere, JAM seems familiar, but yes, thank you, this is my nr1 solution for the prob!
0
 
LVL 3

Author Comment

by:dkellner
ID: 21918730
And also thanks to you Steve, anyway. I'm gonna check those, too, but this JAM thing is completely and exactly what I need. (As far as I can see right now.)
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In our object-oriented world the class is a minimal unit, a brick for constructing our applications. It is an abstraction and we know well how to use it. In well-designed software we are not usually interested in knowing how objects look in memory. …
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now