Solved

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

Posted on 2004-04-27
6
295 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
  • 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

863 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

18 Experts available now in Live!

Get 1:1 Help Now