Solved

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

Posted on 2004-04-27
6
296 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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 

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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
build html 5 client that connect to indy Tidtcpserver 3 395
delphi exception 7 64
HTML text in the body of an email (delphi code) 12 117
Reconfigure Delphi Install? 2 51
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

773 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