[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


OpenDialog behavior

Posted on 2012-09-06
Medium Priority
Last Modified: 2012-09-07
I'd like to be able to select a file from an existing directory, so I set the OpenDialog's InitialDir to that known to exist directory. Subsequently, when the OpenDialog method is executed, how can I prevent users from browsing to other drives and directories?

I've set the option 'ofNoChangeDir' to true which apparently does not function.

OpenDialog2.InitialDir := DesiredDir;       // I want users tied to this directory
OpenDialog2.Filter := 'Text files|*.txt|';
if OpenDialog2.Execute then
   FileNameSelected.text := openDialog2.Files[0];

TIA - Ed
Question by:Ed Covney
  • 4
LVL 19

Expert Comment

ID: 38375078
Use TFileOpenDialog events OnFolderChange and OnFolderChanging...
Delphi OpenDialog without letting the user navigate away from the inital dir
LVL 19

Expert Comment

ID: 38375115
TFileOpenDialog only available for Delphi versions 2009+
LVL 19

Expert Comment

ID: 38375123
With TOpenDialog in older Delphi versions, you can try using CDM_HIDECONTROL for hiding the buttons to prevent folder change...
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

LVL 28

Assisted Solution

by:Sinisa Vuk
Sinisa Vuk earned 375 total points
ID: 38375163
... or you can create custom form with TShellListView (under sample tab) component and set custom folder to view it. This way you can have full control.

Assisted Solution

hawkx earned 375 total points
ID: 38375187
As I know, It is no way to restrict user browse within a folder. Maybe you can prompt a message and prevent the dialog close through event OnCanClose, or display a custom dialog with file list.
LVL 19

Accepted Solution

Thommy earned 750 total points
ID: 38375203
Check this former EE post, which provides a solution for your problem...

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

Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
Make the most of your online learning experience.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Loops Section Overview

873 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