Link to home
Start Free TrialLog in
Avatar of dnote
dnote

asked on

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)
Avatar of ovj
ovj

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.
Avatar of dnote

ASKER

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.
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 ...
Avatar of dnote

ASKER

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.
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.

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.
Use the GetOpenFileName Windows API call


Avatar of dnote

ASKER

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.
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.

Well, for directories, use the SHBrowseForFolder API call.
Avatar of dnote

ASKER

The opendialog implements the openfilename dialog, not a directory dialog...

SHBrowseForFolder ??? Where is it ?
ASKER CERTIFIED SOLUTION
Avatar of ygolan
ygolan

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dnote

ASKER

Bingo !!!
Actually the answer from msnell is not that bad either - SHBrowseForFolder is available in ShlObj.pas (Delphi 3).