Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delphi. How to disable Vcl Themes for TFileOpenDialog and TOpenDialog

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.

like image 790
VeryBadUser Avatar asked Dec 06 '22 15:12

VeryBadUser


2 Answers

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];
like image 150
RRUZ Avatar answered Jan 25 '23 23:01

RRUZ


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);
like image 45
EugeneK Avatar answered Jan 26 '23 00:01

EugeneK