Solved

Listing with TListView

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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
code issue 8 132
Error E2158 compiling with Delphi XE10 Seattle 2 100
Find and Replace Stream with 0s 8 63
tvirtualstringtree freeze when load too manny images 10 63
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

803 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