Solved

TOpenDialog problem - even when i use filter, the user can view all file types

Posted on 2004-04-27
6
302 Views
Last Modified: 2010-04-05
Hi,
I have a problem when using the TOpenDialog component in Delphi (6).
In design time, I put filter, in order to block the user from getting to all files types.
The problem arose when the user is writting in the textbox for the filename "*.*"
Then, he can browse all file types, eventhough the filter is still selected.

Does anyone know what to do?

Thanks,

Dudi
0
Comment
Question by:Dudic
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 6

Assisted Solution

by:pritaeas
pritaeas earned 50 total points
ID: 10936021
Hi. You could try to set the editbox to read-only. If you override the TOpenDialog, you can override the constructor for the form, and set the readonly property to try. Then use your own new OpenDialog, instead of the standard one.

hth, Hans 'pritaeas' Pollaerts
0
 

Author Comment

by:Dudic
ID: 10936088
Hi,
First, thanks for the quick reply.

I checked the read-only property that the TOpenDialog object has, but it is not working as you described.
When i set it to True, still the user can write down whatever he wants in the textbox, and can see all files.

Dudi
0
 
LVL 6

Expert Comment

by:pritaeas
ID: 10936114
No. That's correct. You'll have to derive a *new class* from TOpenDialog and override it's constructor. There, set the EditBox.ReadOnly to True.

Something like this:

type
  TMyOpenDialog = class(TOpenDialog)
  public
    constructor Create(AOwner: TComponent); override;
  end;

constructor TMyOpenDialog.Create(AOwner: TComponent);
begin
  inherited;
  EditBox.ReadOnly := True; // You'll have to check the name here in the code of topendialog, because I do not have delphi here and cannot check myself.
end;

Greetz, Hans
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Dudic
ID: 10936454
I have the code for TOpenDialog and there is no data member by the name of EditBox, or any other name.
Thus, I can't access the ReadOnly property of this field.

I checked the classes that TOpenDialog is deriving from and nothing.

thanks
0
 
LVL 6

Expert Comment

by:pritaeas
ID: 10936467
Hmm. Sorry, I can't check here. No Delphi. I'll see if I can get the info somewhere else.
0
 
LVL 1

Accepted Solution

by:
AngelRider earned 50 total points
ID: 10942827
TOpenDialog.Options contains a flag called ofExtensionDifferent, which is set at run-time if the user selects a file with an extension that is not the same as TOpenDialog.DefaultExt - you could check for this in the dialog's SelectionChange event and take any action you wanted.

This might give you at least a workaround to prevent users opening the wrong files, even though they can still see them...
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Suggested Courses
Course of the Month10 days, 8 hours left to enroll

628 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