Solved

Opendialog Select Directory

Posted on 2002-03-27
2
336 Views
Last Modified: 2010-04-04
Is there a way to only select a directory without selecting a file using the OpenDialog or some other component? But it should be able to select files as well.

Thanx

Skynergy
0
Comment
Question by:skynergy
2 Comments
 
LVL 17

Accepted Solution

by:
inthe earned 50 total points
ID: 6903813
hi,
yes you can use SHBrowseForFolder() with the ulFlag set to BIF_BROWSEINCLUDEFILES

example:

uses activex,shlobj;

procedure TForm1.Button1Click(Sender: TObject);
var
pi: PItemIDList;
selected : array[0..MAX_PATH] of Char;
bi : TBrowseInfo;
begin
FillChar(bi,SizeOf(bi),#0);
bi.pszDisplayName := @selected[0];
bi.lpszTitle := 'Please Select a Folder';
bi.ulFlags := BIF_BROWSEINCLUDEFILES;
pi := SHBrowseForFolder(bi);
if Assigned(pi) then begin
if SHGetPathFromIDList(pi,selected) then
ShowMessage(selected);
end
else ShowMessage('no selection');
CoTaskMemFree(pi);
end;


Regards Barry
0
 

Author Comment

by:skynergy
ID: 6966845
Thanx Barry!
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

685 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