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)
There are some other appearance problems, like:
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:
To reproduce:
- Create new VCL Application
- Place a button and TFileOpenDialog on its main form
- Define OnClick event for the button that calls FileOpenDialog1.Execute
- In Project->Options->Appearance tick some custom styles
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?
Vcl.Styles.SysControls
to theuses
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