Given the following test form (tested in Delphi 10.1 and Delphi 2007):
object Form1: TForm1
Caption = 'Form1'
ClientHeight = 340
ClientWidth = 639
object b_Test: TButton
Caption = 'Test'
OnClick = b_TestClick
end
object od_test: TOpenDialog
Filter = 'blub (blub*.dbf)|blub*.dbf|bla (bla?.dbf)|bla?.dbf'
end
end
(I left out some default properties, basically it's a form with a TOpenDialog and a button. The only important part is the TOpenDialog.Filter property.)
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
od_test: TOpenDialog;
b_Test: TButton;
procedure b_TestClick(Sender: TObject);
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.b_TestClick(Sender: TObject);
begin
od_test.Execute;
end;
end.
Why does the dialog show the filter containing a question mark twice like this:
Is this a known bug or am I doing anything wrong? If it's a known bug, is there a workaround (apart from the obvious one of leaving out the ' (bla?.dbf)' part of the description which would mean I had to change all descriptions.)?
EDIT: This is on Windows 8.1. I haven't tried other versions yet. And in case it makes a difference: I have disabled the explorer option "Hide extensions for knonw file types".
'blub|blub*.dbf|bla|bla?.dbf'
. Repeating the mask in the name is not necessary. So in your setup, thebla (...) (...)
is actually correct, butblub
should also have beenblub (...) (...)
. – Rudy Velthuis'blub (xxx)|blub*.dbf|bla (yyy)|bla?.dbf'
, then I getblub (xxx) (blub*.dbf)
andbla (yyy) (bla?.dbf)
. But if I specify the same string as in the question, I get the same result. Apparently the open dialog scans the filter names for such () entries and if they are the same as the filter, they are only displayed once. It apparently recognizes *, but not ? as wildcard, so it does not remove the double entry for bla. – Rudy Velthuis'blub|blub*.dbf|bla|bla?.dbf'
then the dialog shows'blub (blub*.dbf)'
and'bla (bla?.dbf)'
, at least in 10.1 Berlin and Windows 10. Bit as far as I can remember, this has always been the case, and I have always defined fitlers like that. There is no need to repeat the mask in the filter name. – Rudy Velthuis