8
  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

Thomas
  • 375
  • 1
  • 2
  • 11
  • Sorry, can't reproduce it. Windows 7 Ultimate 64 bit, but compiled with Berlin as 32 bit target. Could you edit your question to show the Windows version? Anyway, my messagebox shows fine. Are you using a scaling factor, e.g. 120% or 150% in your Windows settings? Here, the SaveDialog as well as the messagebox use Amakrits, and all looks fine. – Rudy Velthuis Jul 20 '16 at 16:00
  • 1
    FWIW, the SaveDialog looks like an XP dialog box, not the Explorer style you usually see in Win7+. But the question is good, +1. – Rudy Velthuis Jul 20 '16 at 16:07
  • 1
    I cannot recreate this either, using Delphi 10 Seattle under Windows 10 Pro 64bit. Can you show us a screenshot of what you're talking about? – Jerry Dodge Jul 20 '16 at 16:08
  • 1
    @JerryDodge: if themed, does your Save Dailog look like an XP one recently visited places on the left) or like a Windows 7/8/8.1/10 one, e.g. more or less like a slightly smaller explorer (treeview on the left, listview on the right, etc.)? – Rudy Velthuis Jul 20 '16 at 16:21
  • 1
    @Rudy Interesting, without the theme, it shows the newer dialog style (tree view), but with a theme, it shows the old XP one (Quick Access, Desktop, Libraries, This PC, and Network buttons). – Jerry Dodge Jul 20 '16 at 16:31
  • @JerryDodge: same here. I guess the current save dialog was not so easy to theme. – Rudy Velthuis Jul 20 '16 at 16:50
  • I can't reproduce the issue which you describe, Can you please attach a sample image? Also the original code to style the system dialogs is part of the [VCL Styles Utils](https://github.com/RRUZ/vcl-styles-utils) project. Starting with RAD Studio Seattle EMB acquire a small part of the code to styling the dialogs, so only the classic open/save dialogs are supported by the Embarcadero VCL Styles version. If you want full support for the New Dialogs try the `VCL Styles Utils` project. – RRUZ Jul 20 '16 at 17:44
  • @JerryDodge: If I use `GetSaveFileName()` with the appropriate settings, I see a themed Explorer-style dialog, but the two round buttons at the top left (back, forward) are not styled properly. I guess that is why they decided to use the old XP style. – Rudy Velthuis Jul 20 '16 at 17:45
  • FWIW, I tried this on Win10 too, and it works as expected. I don't see a mutilated message box like in the picture. Here, it looks fine. – Rudy Velthuis Jul 21 '16 at 10:15
  • Oh! I saw this actually, now that you show a screenshot. This happened randomly in a save dialog in our own software about a month ago. After rebooting Windows, it started showing fine again. – Jerry Dodge Jul 21 '16 at 14:47
  • @Rudy: Thanks Rudy. I just want to make sure that you use win32?I get the error every time even if Windows 10 is rebooted. Could we exchange exe-files to see if there will be a difference on each others PC? Does anyone know if I can disable the style theme for the save dialog only (as it appears in the case of using XE8)? – Thomas Jul 21 '16 at 17:09
  • I used Win32 and Win64. No differences. Did you try my GetSaveFileName example? How does that do for you? – Rudy Velthuis Jul 21 '16 at 17:12
  • Trying with "GetSaveFileName(OFN)" will also not work for me in win32 (win 64 is ok), see picture #4 above. – Thomas Jul 21 '16 at 17:22

4 Answers4

4

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

RRUZ
  • 134,889
  • 20
  • 356
  • 483
2

I cannot confirm the problem, and all looks well here, (32 bit executalbe, themed with Amakrits, compiled with 10.1 Berlin, on Windows 7, 100% scaling) but you could try this:

uses ... Winapi.CommDlg;

...

var
  OFN: TOpenFileName;
begin
  FillChar(OFN, SizeOf(OFN), 0);
  OFN.lStructSize := SizeOf(OFN);
  OFN.nMaxFile := MAX_PATH;
  OFN.Flags := OFN_OVERWRITEPROMPT or OFN_HIDEREADONLY or OFN_ENABLESIZING or OFN_EXPLORER;
  GetSaveFileName(OFN);
end;

The result is an Amakrits-themed, new Explorer-like save dialog, which works fine (for me). Only the two round, blue "back" and "forth" (<- and ->) buttons at the top left of the dialog look a little weird.

But I did not try this with custom scaling settings (e.g. Medium 125% in the Control Panel -> Display panel, etc.). I think this could influence such things.

Update

I just tried to use SaveDialog1 (commenting out the OFN code above) with custom Display scaling (125%). All looked fine, so that is not it. Also when I use the OFN code, all looks fine (actually, better, i.e. no XP style dialog, but a real Explorer-like dialog instead).

Community
  • 1
  • 1
Rudy Velthuis
  • 28,387
  • 5
  • 46
  • 94
1

If I set "Enable High-DPI" to true in Project/Options/Application it will work (replace box properly displayed). Disabling it will cause the problem (both in win32 and win64).

Thomas
  • 375
  • 1
  • 2
  • 11
1

For the record, I had exactly the same problem (Delphi 10.1 Berlin, compiling on Windows 10 64 bit, 100% screen settings, compiled for 32 bit target). Enabling or disabling High-DPMI awareness didn't help.

A workaround is to disable styles for dialog boxes before executing the TSaveDialog (or TOpenDialog) like this:

  TStyleManager.SystemHooks := TStyleManager.SystemHooks - [shDialogs];

The file dialog itself will still be themed. You will get standard Windows-style message boxes in case an overwrite prompt (or create prompt) pops up, but they will be large enough for the user to read and click them. After the file dialog has finished, you can enable styled dialogs again by re-adding shDialogs to SystemHooks if needed.