Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 583761
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:49:36+00:00 2026-05-13T14:49:36+00:00

While showing a save dialog, I want to hook user’s filter type change and

  • 0

While showing a save dialog, I want to hook user’s filter type change and change file extension automatically. (e.g. like MSPaint’s “Save As” operation.)

With TSaveDialog and setting UseLatestCommonDialogs := False,
I can handle this by the following code. (without latest common dialog support, of cource.)

procedure TForm1.SaveDialog1TypeChange(Sender: TObject);
var
  FName, Ext: string;
begin
  with TSaveDialog(Sender) do
  begin
    if DirectoryExists(FileName) then // FileName is Empty
      exit;
    case FilterIndex of
    1: Ext := '.png';
    2: Ext := '.bmp';
    3: Ext := '.jpg';
    end;
    FName := ChangeFileExt(ExtractFileName(FileName), Ext);
    SendMessage(Windows.GetParent(Handle), CDM_SETCONTROLTEXT, 1152, LongInt(PChar(FName)));
  end;
end;

I want to support both XP, and vista/7 with Delphi 2007.

Should I use TFileSaveDialog instead of TSaveDialog with internal wrapper ?
(And I have to struggle with COM programming using IFileDialogControlEvents ?)

Or can I achieve this with TFileSaveDialog and it’s standard properties only ?
(My development environment is still on XP machine, so I’ve never tried. sorry.)

I think it’s very common task, but I couldn’t find any sample code supporting Vista/7…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T14:49:37+00:00Added an answer on May 13, 2026 at 2:49 pm

    As far as I know, TFileSaveDialog will raise an exception on XP. It needs Vista or up.

    Update: some D2010 code for TFileSaveDialog adapted from your event handler….
    (I don’t have D2007 on Vista; use PWideChar instead of PChar)

    procedure TForm1.FileSaveDialog1TypeChange(Sender: TObject);
    var
      FName, Ext: string;
      pName: PChar;
    begin
      with TFileSaveDialog(Sender) do
      begin
        if DirectoryExists(FileName) then // FileName is Empty
          exit;
        case FileTypeIndex of
        1: Ext := '.png';
        2: Ext := '.bmp';
        3: Ext := '.jpg';
        end;
        Dialog.GetFileName(pName);
        FName := ChangeFileExt(ExtractFileName(pName), Ext);
        Dialog.SetFileName(PChar(FName));
      end;
    end;
    

    Where the FileSaveDialog is:

    object FileSaveDialog1: TFileSaveDialog
      FavoriteLinks = <>
      FileTypes = <
        item
          DisplayName = 'png files'
          FileMask = '*.png'
        end
        item
          DisplayName = 'bmp files'
          FileMask = '*.bmp'
        end
        item
          DisplayName = 'jpg files'
          FileMask = '*.jpg'
        end>
      Options = []
      OnTypeChange = FileSaveDialog1TypeChange
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 285k
  • Answers 285k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Your dateFormat is undefined for a start. You need to… May 13, 2026 at 4:39 pm
  • Editorial Team
    Editorial Team added an answer The PowerShell blog and TechNet Scripting with Windows PowerShell page… May 13, 2026 at 4:39 pm
  • Editorial Team
    Editorial Team added an answer '==' is perfectly good for integer values. You should not… May 13, 2026 at 4:39 pm

Related Questions

This is an annoyance that I've tolerated for too long, and finally decided to
Well i have a gridview where i have defined the columns on my own
I have an NSCell subclass that I do all kinds of custom drawing in.
Using VB 6 and Crystal Report 8.5 In client system while generating the report,
I have two processes which exange messages each other. Process A is a normal

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.