?
Solved

Problem with SelectDirectory Function

Posted on 2002-04-16
3
Medium Priority
?
262 Views
Last Modified: 2010-04-04
Hi...
  When the user calls the SelectDirectory function in my app, I want it to default to the root directory (ie. C:\)... but it won't do it. Here's my code:

defdir:='c:\';
if SelectDirectory(defdir,[],0) then
   speedbutton21.hint:=defdir
else speedbutton21.hint:='';

...the SelectDirectory dialog box always comes up with the directory my app is located in, as its selected directory...weird. There seems to be no way I can force it to go to the root directory.

Any thoughts?

Thanks
   Shawn
0
Comment
Question by:aztec
[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
3 Comments
 
LVL 5

Expert Comment

by:alanwhincup
ID: 6946040
You could do it like this:

procedure TForm1.Button1Click(Sender: TObject);
var
  DefDir : string;
begin
  if SelectDirectory('Please choose a directory:', 'C:\', DefDir) then
    speedbutton21.hint := DefDir
  else
    speedbutton21.hint := '';
end;
0
 
LVL 10

Accepted Solution

by:
Jacco earned 200 total points
ID: 6946050
It works if you initialize defdir to "c:\*.*"

Regards Jacco

P.S. It seems to be a small bug in FileCtrl.ProcessPath
0
 

Author Comment

by:aztec
ID: 6946067
that gives a complile error:

"Constant object cannot be passed as var parameter"

I don't think it likes the 'Please choose a directory'...it's expecting a variable.

Shawn
0

Featured Post

Industry Leaders: 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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Suggested Courses

770 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