Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Custom Component for browsing files (base: TListBox)

Status
Not open for further replies.

abcfantasy

Programmer
Jun 3, 2006
110
DK
Hello,
I'm creating this custom component derived from TListBox used for file browsing. I use FindFirst and FindNext to get the list of directories and files and add them to the list.

The question is, how do I display the contents of My Computer? That is, displaying the logical drives, floppy drives, cd drives, etc...

I don't think FindFirst and FindNext could be of use here.

Any help?
Thanks in advance
Andrew

ABC -
 
in the windows unit we have the:
GetLogicalDrives
GetDriveType
GetDiskFreeSpace
GetLogicalDrivesStrings

may help you, but I haven´t use these yet...

hope it helps

"Suffering, anguish, desperation and hard work are the materials a good programmer is made of." (buho (A))
"and against short remaining time..." (me)
 
Use the OpenDialog component found on the Dialogs Tab. It will invoke the File Open dialog used by windows

Regards

Steven
 
Thanks for your help.

I took part of the TDriveComboBox source and changed it a little to suit my component.

For those who may be interested, this is the procedure:

Code:
procedure TFileBrowser.BuildDriveList;
var
  DriveNum: Integer;
  DriveChar: Char;
  DriveBits: set of 0..25;

begin
  Clear;
  Integer(DriveBits) := GetLogicalDrives;
  for DriveNum := 0 to 25 do
  begin
    if not (DriveNum in DriveBits) then Continue;
    DriveChar := Char(DriveNum + Ord('a'));
    Items.Append( DriveChar + ':\' );
  end;
end;

ABC -
 
if not (DriveNum in DriveBits) then

???


he is verifing some bits from a cardinal?

is it other way to use then 'in' operator?

"Suffering, anguish, desperation and hard work are the materials a good programmer is made of." (buho (A))
"and against short remaining time..." (me)
 

// The physical format of the set 0..25 is actually a
// dword/integer/cardinal.
DriveBits: set of 0..25;

...

// The integer returned by GetLogicalDrives is typecasted
// into a set (actually, the integer returned is a
// bitmap
).
Integer(DriveBits) := GetLogicalDrives;

A set is a collection of bits, and an integer is a collection of bits too. Any bitwise operation can be done with sets and viceversa (using the due typecasts).

buho (A).
 
I never had think about it...

I could see it by my self!

"Suffering, anguish, desperation and hard work are the materials a good programmer is made of." (buho (A))
"and against short remaining time..." (me)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top