Solved

Listing with TListView

Posted on 1998-04-02
5
461 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

749 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