Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2169
  • Last Modified:

Need a Delphi component to list files in various folders

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
dkellner
Asked:
dkellner
  • 9
  • 5
  • 5
  • +3
1 Solution
 
SteveBayCommented:
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
 
JohnjcesCommented:
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
 
dkellnerAuthor Commented:
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
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
SteveBayCommented:
So what is wrong with using a TListView in Report mode? That is basicly what it is designed to.
0
 
SteveBayCommented:
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
 
dkellnerAuthor Commented:
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
 
dkellnerAuthor Commented:
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
 
SteveBayCommented:
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
 
dkellnerAuthor Commented:
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
 
Geert GOracle dbaCommented:
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
 
Geert GOracle dbaCommented:
um slight misphrasing ...
you can't have 1 file in multiple locations ,
0
 
dkellnerAuthor Commented:
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
 
Geert GOracle dbaCommented:
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
 
Geert GOracle dbaCommented:
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
 
dkellnerAuthor Commented:
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
 
Martin BarredaLic. in Computer ScienceCommented:
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
 
Geert GOracle dbaCommented:
Hey don't forget the drag and drop features ...
0
 
dkellnerAuthor Commented:
Thank you spk but this is absolutely not what I'm looking for.
0
 
alkisgCommented:
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
 
alkisgCommented:
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
 
SteveBayCommented:
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
 
dkellnerAuthor Commented:
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
 
dkellnerAuthor Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 9
  • 5
  • 5
  • +3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now