1
votes

I have some problems when using a Vista-style TFileOpenDialog in a Delphi 10.1 Berlin VCL application with VCL styles on Windows 10 64-bit. The biggest problem is that the Open button appears as a Radio button:

(Red ??? are added by me)

Windows 10 Blue Style

Iceberg Classico Style

There are some other appearance problems, like:

image

but they can be ignored for now.

TFileSaveDialog does not have the same problem with the Save button, but does have the same problem with the address bar.

It is most likely a problem with Windows 10 itself, because on Windows 10 the Open button is a Split button:

image

To reproduce:

  1. Create new VCL Application
  2. Place a button and TFileOpenDialog on its main form
  3. Define OnClick event for the button that calls FileOpenDialog1.Execute
  4. In Project->Options->Appearance tick some custom styles
  5. Select one of them. If you wish - put a combo box (cbStyle) on the form and fill it like this:

    for S in TStyleManager.StyleNames do
      cbStyle.Items.Add(s);
    

    and define on OnChange event:

    if cbStyle.ItemIndex >= 0 then
      TStyleManager.TrySetStyle(cbStyle.Items[cbStyle.ItemIndex]);
    

This will let you to change the styles in run time (and select Windows if no styles are required)

The problem also persists when GetOpenFileName() from Winapi.CommDlg is used:

procedure TForm1.Button1Click(Sender: TObject);
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;
  GetOpenFileName(OFN);
end;

Up until now, I can try to use a hack: hide the original Open button and replace it with another one (Pushbutton style), but I did similar things many years ago with standard dialog boxes - adding a check box, for example. Not sure whether a similar approach would work.

Or, I could forget about TFileOpenDialog and just use the good old XP style TOpenDialog.

Does anybody have a solution?

1
Not a problem with Windows 10. You aren't running Windows 10 code. You replaced it with VCL styles code. That relies on implementation details that are subject to change. Applying the fixes from the VCL Styles utils project will likely fix the issue. Until the next release of Windows. That's an aspect of VCL styles that Emba dont tell you, that they are liable to break any time new release of Windows come along. No future proofing at all. Avoid all the headaches by avoiding VCL styles.David Heffernan
Have you tried using the VCL Styles Utils? It fixes things exactly like this. I'm surprised you've had as much success as you already have with VCL Styles in Windows dialogs.Jerry Dodge
No, VCL Styles Utils (excellent work from RRUZ!) do not fix the problem (unless there were recent changes). May be related to the fact that Windows 10 updated recently... I will download the latest version and try.roumen
Manifest file you have up to date?Victoria
And you're sure you added Vcl.Styles.SysControls to the uses clause of this problematic form? FWIW, I use the exact same combo as you, and don't have your problem, whether I use the utils or not.Jerry Dodge

1 Answers

1
votes

The problem does not appear if:

  • vcl-styles-utils are used AND
  • vcl.styles.utils.stdCtrls is added to the uses clause of the unit that calls the dialog Execute method (in my case the dialog is placed in a Data module).

Thank you Rodrigo Ruz for the excellent work! The appearance problems are also fixed: VCL Stile "Windows 10 Blue"

(almost - see Cancel button on Tablet style - but it can be ignored!): VCL Style "Tablet Light"

Thank you Jerry Dodge for the hint!

Fed up of half baked features from Embarcadero - shipped just to "tick the box" and add to the "feature list"!