[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

setting the top level viewable folder on a TDirectoryListBox

Posted on 2005-05-12
11
Medium Priority
?
479 Views
Last Modified: 2008-01-16
Hi,

I would like to modify Delphi 7's existing TDirectoryListBox, so that I can set a top level folder.

eg:

If I set the top level folder to be c:\games then the user can only browse the folder c:\games and below, but nothing above it or on the same level. Is this possible? I'm looking for the required code to make the modification, or some insight could be shared on what functions to override.

Thanx
0
Comment
Question by:CyberBOB6
  • 4
  • 4
  • 3
11 Comments
 
LVL 1

Author Comment

by:CyberBOB6
ID: 13994057
maybe some more points will spart a response :(
0
 
LVL 15

Expert Comment

by:mikelittlewood
ID: 13994200
Where is this component from? I would need to see what properties are available for use before I could try and give you an answer   :o)
0
 
LVL 15

Expert Comment

by:mikelittlewood
ID: 13994394
How about using a TShellTreeView instead?
This component has a property called "Root" which you could set to "c:\games".
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 15

Expert Comment

by:mikelittlewood
ID: 13994412
The component is under the "Samples" tab by the way.
0
 
LVL 11

Expert Comment

by:ZhaawZ
ID: 14000749
A simpliest way - use onChange event to check folder.

procedure TForm1.DirectoryListBox1Change(Sender: TObject);
var
  dir1 : string;
  dir2 : string;
begin
dir1 := 'd:\games\'; // allowed top directory
dir2 := DirectoryListBox1.Directory + '\'; // current directory
if not SameText(copy(dir2, 1, length(dir1)), dir1) then begin // if current directory is not within allowed top directory, then
  DirectoryListBox1.Directory := dir1; // change current directory to allowed top directory
end;
end;
0
 
LVL 1

Author Comment

by:CyberBOB6
ID: 14001674
Thanx, I have tried this method before, and while it works, it's not what I want. The user must not be able to view the folders that he cannot browse to. And thats the part I'm finding hard to implement.
0
 
LVL 11

Expert Comment

by:ZhaawZ
ID: 14001710
Well, in this case you could create your own dirlist component from TListBox (without using TDirectoryListBox)
0
 
LVL 1

Author Comment

by:CyberBOB6
ID: 14001714
I'm not looking to re-invent the wheel here, I just want to add a feature to it. Surely there must be a way to modify its listing functions to achieve what I'm trying to do?
0
 
LVL 11

Expert Comment

by:ZhaawZ
ID: 14002054
Well, you'll have to rewrite BuildList procedure of TDirectoryListBox and maybe some other procedures/functions too.

BuildList procedure shows directories and drive letter in TDirectoryListBox - that's why you'll have to rewrite this.
I don't know yet, how TDirectoryListBox browses directories, but I believie you'll have to rewrite this part of TDirectoryListBox too.

I think this is more difficult than writing your own component, but if you want to use customized TDirectoryListBox - good luck ;)
0
 
LVL 15

Accepted Solution

by:
mikelittlewood earned 600 total points
ID: 14017099
Personally I would use the TShellTreeView component. I dont think you would be reinventing the wheel using it, and it has excellent directory properties .. o .. and it actually looks much more professional.
0
 
LVL 1

Author Comment

by:CyberBOB6
ID: 14019366
thanx, ended up using that component ... I didn't even know it could do all that stuff.
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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

865 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