Solved

Open Directory Dialog

Posted on 1997-05-09
14
619 Views
Last Modified: 2010-04-06
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)
0
Comment
Question by:dnote
  • 5
  • 2
  • 2
  • +4
14 Comments
 

Expert Comment

by:ovj
ID: 1336078
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
 

Author Comment

by:dnote
ID: 1336079
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
 
LVL 2

Expert Comment

by:gysbert1
ID: 1336080
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
 

Author Comment

by:dnote
ID: 1336081
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
 
LVL 3

Expert Comment

by:sperling
ID: 1336082
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
 
LVL 2

Expert Comment

by:gysbert1
ID: 1336083
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
 

Expert Comment

by:msnell
ID: 1336084
Use the GetOpenFileName Windows API call


0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 

Author Comment

by:dnote
ID: 1336085
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
 
LVL 2

Expert Comment

by:icampbe1
ID: 1336086
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
 

Expert Comment

by:msnell
ID: 1336087
Well, for directories, use the SHBrowseForFolder API call.
0
 

Author Comment

by:dnote
ID: 1336088
The opendialog implements the openfilename dialog, not a directory dialog...

SHBrowseForFolder ??? Where is it ?
0
 
LVL 1

Accepted Solution

by:
ygolan earned 100 total points
ID: 1336089
Check out the SelectDirectory procedure in the online help.
0
 

Author Comment

by:dnote
ID: 1336090
Bingo !!!
0
 
LVL 1

Expert Comment

by:ygolan
ID: 1336091
Actually the answer from msnell is not that bad either - SHBrowseForFolder is available in ShlObj.pas (Delphi 3).
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

746 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

11 Experts available now in Live!

Get 1:1 Help Now