[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Listing with TListView

Posted on 1998-04-02
5
Medium Priority
?
467 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 300 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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying 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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

649 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