Open Directory Dialog

Is there a simple way to create a dialog much like a standard Open/Save File Dialog, without having to create it as a component (I like to do this in OWL)
dnoteAsked:
Who is Participating?
 
ygolanConnect With a Mentor Commented:
Check out the SelectDirectory procedure in the online help.
0
 
ovjCommented:
What do you mean by "simple way" and "without having to create it as a component"?
If I've understood your question, you could rather easily create a new empty form and drag components from the toolbar. There are FileListBox, DirectoryListBox, FilterComboBox and DriveComboBox that easily can be connected to each other by e.g. specifying the directory TLabel to be updated by the TDirectoryListBox, the file list (TListBox) to be updated by the TDirectoryListBox, etc.
Read the help for TDirectoryListBox and TDriveComboBox to find out more. It only takes 5-10 minutes to create such dialogs.
0
 
dnoteAuthor Commented:
Dear ovj,
I do not want to use any components nor a form. I just wanna
use the standard dialogs in windows and change them so that
it becomes a directory dialog. In the help for API from Delphi
it says you can do something like this, but doesn't show any
examples on it. Under no circumstances I wanna use the Forms
unit !

Dnote.
0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

 
gysbert1Commented:
If you do not want to use the forms unit or components I strongly suggest you stick to BP7 or C++ to work in windows since delphi's equivalent to the C++ OWL IS its components and the forms unit.

If you really want to do this the best will probably be to stick the file dialog calls in a dll that uses OWL calls, but this will get very nasty sizewise for your app.

The best advise I can give is to use the forms and the components provided unless you have a very good reason not to.

If you can provide such a reason I will gladly try to help you on this one ...
0
 
dnoteAuthor Commented:
The reason is that I dont want my app to start at 160kB in size, with OWL I managed about 40kB, and I want to keep it round that size.

It IS possible to do OWL within delphi, look in delphi\source\rtl70 to find the source code.
0
 
sperlingCommented:
The standard file open dialog does not allow for directory selection. You need to modify it using a dialog template resource. If you've experienced with "old-fashioned" windows programming, start looking at help for Win API function GetOpenFileName and friends. If not, you've got a problem ;)

I can't say anything besides that the size of the EXE is what you have to pay for using a RAD tool... If you've got D3, you could use the VCL30 dll instead of compiling it into your app, but it probably ain't any good with a 40k app relying on 1.3MB DLL....

Regards,

Erik.

0
 
gysbert1Commented:
Have a look at the files you have to ship with that 40k app of yours to allow it to work on a machine not running BC4 or similar. The OWL200.dll alone is 550k. If you are using BC4 you have to include bc40.dll, etc.

Compile your OWL app with all the libraries statically linked and you will end up with the same size app as with delphi.

The advantages of using .dll's are obvious, but an extra 100K in your app is not much considering the massive hard drives users have nowadays.

I wish all programmers were so concerned with keeping app size down. It seems to be a dying art nowadays !

Thus : Do as sperling says if you have to reduce the size. You are going to pay heavily with your time though ! Otherways jump in and follow the rest of us Delphi fans.
0
 
msnellCommented:
Use the GetOpenFileName Windows API call


0
 
dnoteAuthor Commented:
Dont get me wrong, I AM a Delphi fan, but just with this program I wanted do it in old fashion windows programming way. I don't understand what you are meaning by those .dll's. My program doesn't require any. Maybe I've not been clear about a point, I am using just Delphi to compile the source in an equivalent way  like BP70 would. I'm caring about the program size because it is to be a Setup program, which in my opinion has to be relative small. What the GetOpenFileName concerns, it doesn't do the job, since I want to select a directory not a filename.
If anybody could send me some source with an example of a custom dialog template/hook, it would be greatly appreciated, the online help of delphi doesn't seem to dig very deep in the material.
0
 
icampbe1Commented:
I Think I might have an idea.  First of all, the dll's that are being talked about are the ones that get used behind your back.  If the EXE is thin, then its a safe bet that the dll it uses (maybe not explicitly) is sizable.

Anyhow, try this... In a dll (a unit with no form), declare a VAR of the type you want (VAR tt: TOpenDialog for example).  Then create an instance of that class:   tt := TOpenDialog.Create( NIL );  Then use the dialog with  tt.Execute.  Of course, you wrap all of this in a procedure that you export from the dll and call from an external program (like your setup pgm).

Dont forget to free to object when your done!  Also, enclose the whole thing in a TRY EXCEPT to keep any exceptions from escaping the dll.

Hope this helps.  (I have not tried this by the way, but I will tonite).

Cheers.

0
 
msnellCommented:
Well, for directories, use the SHBrowseForFolder API call.
0
 
dnoteAuthor Commented:
The opendialog implements the openfilename dialog, not a directory dialog...

SHBrowseForFolder ??? Where is it ?
0
 
dnoteAuthor Commented:
Bingo !!!
0
 
ygolanCommented:
Actually the answer from msnell is not that bad either - SHBrowseForFolder is available in ShlObj.pas (Delphi 3).
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.