问题
How to disable Vcl Themes for TFileOpenDialog and TOpenDialog ?
I try
procedure TForm1.FormCreate(Sender: TObject);
var
chosenDirectory: String;
openDialog : TFileOpenDialog;
begin
TStyleManager.Engine.RegisterStyleHook(TFileOpenDialog, TStyleHook);
chosenDirectory:='';
try
openDialog:=TFileOpenDialog.Create(Self);
openDialog.Options := [fdoPickFolders];
// var 2
// Not works
//TStyleManager.Engine.RegisterStyleHook(TFileOpenDialog, TStyleHook);
if openDialog.Execute then
chosenDirectory:=openDialog.FileName;
finally
openDialog.Free;
end;
end;
but it's not work. I try variation 2. It's not work too.
回答1:
It does not work because FileOpenDialog is system windows dialog, rather than implemented in VCL, so you'll need add system hook based on class name. Plus you'll need to add hooks to class names of all Windows controls on this dialog.
Try something like this. Note that this will affect all system dialogs.
TStyleManager.Engine.RegisterSysStyleHook('#32770', TSysStyleHook);
TStyleManager.Engine.RegisterSysStyleHook('ReBarWindow32', TSysStyleHook);
TStyleManager.Engine.RegisterSysStyleHook('Static', TSysStyleHook);
TStyleManager.Engine.RegisterSysStyleHook('Edit', TSysStyleHook);
TStyleManager.Engine.RegisterSysStyleHook('ScrollBar', TSysStyleHook);
TStyleManager.Engine.RegisterSysStyleHook('ToolbarWindow32', TSysStyleHook);
TStyleManager.Engine.RegisterSysStyleHook('ComboBox', TSysStyleHook);
回答2:
The proper way of disable the styling of the common dialogs is removing the shDialogs element of the TStyleManager.SystemHooks property.
TStyleManager.SystemHooks := [shMenus, shToolTips];
来源:https://stackoverflow.com/questions/41656918/delphi-how-to-disable-vcl-themes-for-tfileopendialog-and-topendialog