Solved

Problem with SelectDirectory Function

Posted on 2002-04-16
3
252 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
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 50 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How can I load a text file into a TVirtualStringTree? 17 105
Newbie Thread Programming 1 139
Delphi Form ownership 4 70
Firemonkey DbLookupComboBox equivalent ? 2 32
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
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…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
Delivering innovative fully-managed cloud services for mission-critical applications requires expertise in multiple areas plus vision and commitment. Meet a few of the people behind the quality services of Concerto.

929 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now