Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2004-04-27
6
Medium Priority
?
305 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 200 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
Independent Software Vendors: 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 200 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

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
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…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

730 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