What is the difference between the new TFileOpenDialog and the old TOpenDialog?

InTheNameOfScience picture InTheNameOfScience · Jun 4, 2011 · Viewed 9.7k times · Source

What is the difference between the new TFileOpenDialog and the old TOpenDialog?
In my computer (Win 7/DXE), when I run the code, the dialogs look the same.

Answer

Uwe Raabe picture Uwe Raabe · Jun 4, 2011

TOpenDialog executes TFileOpenDialog when the following conditions are met:

  1. the program is running under Vista or Windows 7
  2. UseLatestCommonDialogs is true (which is the default)
  3. no OnIncludeItem, OnClose or OnShow events are set

So while still using TOpenDialog on your system you may likely end up automagically executing TFileOpenDialog in most cases, which explains why they are looking the same for you.

Remark: TFileOpenDialog does not fall back on older Windows systems - it just raises an exception. On the opposite, TOpenDialog does some sort of "fall forward".