delphisave-dialogtsavedialog

TSaveDialog and 2 formats with same extension


In TSaveDialog I added 2 formats with the same extension:

Format A|*.form
Format B|*.form
Format C|*.diff

Now I want to identify which format user chose:

var Ext: String;
begin
  if not SaveDialog1.Execute then Exit;

  Ext := LowerCase(ExtractFileExt(SaveDialog1.FileName));

This way I can differentiate "Format B" from "Format C" but I can't "Format A" from "Format B".


Solution

  • Use the FilterIndex property to identify which filter was selected when the dialog was actioned.