Solved

Problem with SelectDirectory Function

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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

707 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

16 Experts available now in Live!

Get 1:1 Help Now