1

On new Windows versions (it is so at least on Windows 7 but I have reasons to believe it happens on Vista to) IFileDialog (and thus IFileOpenDialog and IFileSaveDialog) automatically append the wildcard pattern to the file type description if they find none.

This is a nice feature to make usage easier while enhancing consistency and enforcement of guidelines. But sometimes it is not desired. If accepted extensions are numerous (like "All Images") then corresponding combobox entry is way too long. The worst thing is that this is not even documented and I only found a note about it (confirming my observations) at CodeProject article.

On Windows 7 the backward compatibility checking (as mentioned by CodeProject article) is not so strong and it seems any patterns manually appended to description will prevent automatic appending. This was already pointed out by an answer to another question. Yet this solution is far from ideal. (I decided to ask the same question again as I believe the previous one was poorly tagged and described: (1) I found it first by looking at similar questions suggested by StackOverflow, my previous queries in Google didn't found it and (2) the issue is general and not limited to Delphi.)

How to prevent this?

Note that I have to use IFileDialog because I need the customizations it offers. (So switching to dialog produced by GetOpenFileName and GetSaveFileName is not an option.)

Community
  • 1
  • 1
Adam Badura
  • 5,069
  • 1
  • 35
  • 70
  • This is a dupe, regardless of how you try to justify it. The other question you linked to provides an answer that isn't Delphi specific, and you've really asked nothing differently here (or provided any additional information other than the CodeProject link). – Ken White May 21 '11 at 23:20
  • The answer provided there is not satisfying. It wasn't even accepted which proves the point. And I do belive there must be some solution only the question was asked in a way which strongly reduced number of people who saw it. – Adam Badura May 22 '11 at 04:54
  • So maybe lets wait some time and if the question does gather more attention then fine. If not then lets close it then. – Adam Badura May 22 '11 at 05:12
  • 2
    You'd be better off putting a bounty on the other question. – David Heffernan May 22 '11 at 21:31
  • @David Heffernan: I considered that. But didn't do that because I didn't found that question in my initial searches in Google or here. Maybe I should reconsider it again. – Adam Badura May 25 '11 at 23:22

1 Answers1

0

Well, MSDN mentions IFileDialog.SetFilter being deprecated for Windows 7. In that case I guess you have to use IFileDialog.SetFileTypes to set the file extension patterns. As you say that the wildcard extension is already there, the answer is to overwrite the extension patterns by using one of these two functions.

No sample code due to missing language tag. The link to SetFileTypes shows a pretty good example though.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
NGLN
  • 43,011
  • 8
  • 105
  • 200
  • I does not work. If I call `SetFielTypes` with something like `{"All Files", "\*.\*"}' on Windows 7 the dialog will show (in combo box) 'All Files (\*.\*)'. – Adam Badura May 23 '11 at 05:52
  • That's kind of what one would expect, isn't it? Wasn't your question about the reverse? – NGLN May 25 '11 at 20:11
  • Yes. I don't want it because the list of extensions is very long (take for example All Images...). And I think the question is rather obvious at what I want. – Adam Badura May 25 '11 at 23:20