Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Property "ofOverwritePrompt" for TSaveDialog does not work when VCL Styles are used in Delphi 10.1 Berlin

  1. Create a new VCL Forms application
  2. On the main form add a Tbutton and a TSaveDialog

  3. Set "ofOverwritePrompt" to True in properties for the SaveDialog1

  4. Use:

    procedure TForm1.Button1Click(Sender: TObject);
    begin
      SaveDialog1.Execute();
    end;
    
  5. Run the app. Press the button to execute the save dialog. Try to save to a file that already exists. A message box appears if you want to replace the file. Press cancel. All fine so far. Close the app.

  6. Go to Project/Options/Application/Appearance and select a Custom style (e.g. Amakrits). Set Amakrits as the default style.

  7. Run the app as in #5 above. Only a small bit of the message box will be shown. You will have to press Enter to be able to continue.

(Using a TFileSaveDialog will give the same result)

If I compile and run the app using Delphi XE8 it will be ok since the save dialog window seems to use the default windows style even if another style is chosen.

Edit: I have Windows 10 pro. Source compiled as win32 with Delphi 10.1 Berlin. The replace message box is partly hidden. Only a small top left part is shown, see figure.

The replace message box is partly hidden. Only a small top left part is shown.

And here it is compiled with XE8 win32:

enter image description here

Ps. I am using the default 100% scale factor.

Compiling with win64 (Delphi 10.1 Berlin) seems to be ok:

enter image description here

So, compiling to win32 does not work for me, but 64-bit will. Any clues?

Edit: Trying with "GetSaveFileName(OFN)" will also not work for me in win32 (win 64 is ok):

enter image description here

like image 997
Thomas Avatar asked Jul 20 '16 15:07

Thomas


1 Answers

You can avoid this issue using the dialog styling code of the VCL Styles Utils project.

Just Add these units to your project.

uses
  Vcl.Styles.Utils.Menus, //Popup and Shell Menus (class #32768)
  Vcl.Styles.Utils.Forms, //dialogs box (class #32770)
  Vcl.Styles.Utils.StdCtrls, //buttons, static, and so on
  Vcl.Styles.Utils.ComCtrls, //SysTreeView32, SysListView32
  Vcl.Styles.Utils.ScreenTips, //tooltips_class32 class
  Vcl.Styles.Utils.SysControls,
  Vcl.Styles.Utils.SysStyleHook;

{$R *.dfm}

procedure TForm26.Button1Click(Sender: TObject);
begin
  UseLatestCommonDialogs := false;
  SaveDialog1.Execute();
end;

enter image description here

like image 158
RRUZ Avatar answered Oct 14 '22 23:10

RRUZ