Solved

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

Posted on 2004-04-27
6
291 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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
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…
This video discusses moving either the default database or any database to a new volume.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

708 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

12 Experts available now in Live!

Get 1:1 Help Now