Solved

Listing with TListView

Posted on 1998-04-02
5
460 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
ID: 1361236
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
ID: 1361237
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
ID: 1361238
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
ID: 1361239
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
ID: 1361240
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

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

808 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