delphiwinapitopendialog

How to set a sorting mode in Open Dialog


A user can manually sort files in a standard Windows Open Dialog (in "Details" view mode) by Name, Date or Size by clicking on the corresponding column header. How to set a sorting mode in Open Dialog (TOpenDialog class in Delphi) programmatically in application so that the dialog opens with a preferred sorting?


Solution

  • The GetOpenFileName() API and the Vista IFileDialog interface have no support for this. You can hack the dialog as demonstrated in this magazine article. Beware that the article is quite dated. And that hacks like these are brittle, they may well stop working on the next version of Windows.