Solved

Listing with TListView

Posted on 1998-04-02
5
455 Views
Last Modified: 2010-04-06
Hello,

I'm writing an FTP - Client - Application. My idea is to create a program that is very usefriendly. This means, i want a "program-desktop" that consists of 3 main windows. There are two for the local system, a TDirectoryListBox and a TFileListBox and a TLlistView for the remote system. I think i am able to write code, that automatically uploads the clicked file to the server. So this part should be ok.
Now to my problem. I need to List ALL Directories and Files on the server, whenever they change. I know of the OnListItem - Event, but i dont how to list the files and directories on my TListView - Window. This window is divided into 4 groups, FileName, Size, Type and Date. This Window should List both, File and Dirs, like the windows explorer, and i if the user clicks on a file, it should automatically download it.

Thx for help ;)
0
Comment
Question by:omsec
  • 2
  • 2
5 Comments
 
LVL 3

Expert Comment

by:williams2
Comment Utility
The problems you are mentioning are NOT trivial. The easiest way to deal with the directory structure problem, is to make a recursive tree-like solution. when refreshing the directories, you'll have to re-read all available information once again, and that takes time. You should consider handling this like windows handles Discdrives to preserve time.

The TListView is a strange bit strange compared to the TStringGrid component.

First be sure, that you actually have added columns to the Columns property in the TListView object. Thereafter set its ViewStyle to 'vsReport'
When adding a TListItem, You'll have to add set the Caption property, and thereafter adding Size,Type and Date as strings to it's Subitems(TStrings) property. You should consider using Icons too. You should first add a couple of TImageList objects to your form, load some Icons into them, set the Small/Large Image property on your TListView object and then set the ListItem's ImageIndex property to a number within a range between 0 and Imagelist.Count-1.

Enough for now, if you want additional information, you may leave a comment.

Regards
Williams
0
 
LVL 2

Author Comment

by:omsec
Comment Utility
I'm not sure what you mean, cuz i'm quite new with Delphi, so I would be very thankful for some sources. Like I said i have a DirectoryListBox, a FileListBox and a DriveCombo from the Win 3.1 - Component. These three Boxes do the job for the local System and they work fine. My problem is to list the Files/Dirs from the remote System (the FTP-Server). I used TListView, cuz i heard this is able to list both, Files and Directories in Same window. But it doesn't have to be a TListView, if you think i should use something else that can do the same job, its OK also.

I just want to make it look like the example below :

-------------------
<DOS>
<WINDOWS>
AUTOEXEC.BAT
CONFIG.SYS
-------------------
This should show that window... You see it contains both, Files and Dirs. And if the user goes into a Sub-Dir it should look like this :

-------------------
..
<DATA>
FILE.TXT
FILE.SYS
-------------------
The two points (..) should bring you back one Directory higher when you click there. and "Data" would be another Sub-Directory.

So, do you think you could write a lil procedure that list something like that in my Remote-System - Window ?

------------------------------------------
NAME      SIZE      TYPE        DATE
------------------------------------------
..        0         Directory   xx.xx.xxxx
DOS       0         Directory   xx.xx.xxxx
READ.TXT  1000      Text File   xx.xx.xxxx
TEST.EXE  5000      Program     xx.xx.xxxx
PIC.JPG   800       JPEG-PIC    xx.xx.xxxx
------------------------------------------

so, this should give you a lil imagination of my problem. Like i said, when click to a Directory - Sign, it changes the DIR and by a double click on a File it downloads the file. I know how to use GetFile, PutFile etc. and i know that the FTP-Comp. sends out an OnChange - Event or something, but i really have no clue on how to list it. Cuz the two other boxes did that automatically. And umh. i didnt think about Icons yet, but seems to be usefull.

thank you very much, i'll increase the points ;)


0
 

Accepted Solution

by:
skanade earned 150 total points
Comment Utility
Here is the sample code for you. I am assuming that you know how to get the data for your columns. I am just showing how to fill up that data in the listview:

  item: TListItem;
begin
  with ListView do
  begin
    ..for..loop through your data items
    begin
      item := Items.Add;
      item.Caption := ..FileName string..
      item.SubItems.Add(..Size string..);
      item.SubItems.Add(..Date string..);
      item.SubItems.Add(..Type string..);
    end;
  end;

Hope this helps,
Sanjay
0
 
LVL 2

Author Comment

by:omsec
Comment Utility
sorry, i dont know how to get the data from the FTP-Comp. to the Columns. Could you explain that also, please ?

0
 

Expert Comment

by:skanade
Comment Utility
You need to look at the documentation given with that component to see how it works. Sorry, I can't help you there.

Sanjay

0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

728 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

10 Experts available now in Live!

Get 1:1 Help Now