How can I set the default system style in Delphi 1

2019-08-11 06:44发布

问题:

I am trying to port some code that works in Delphi XE8 to Delphi 10 Seattle.

This code sets the default system style of my program, but the SetSystemStyle method does not exist in the Delphi 10 Seattle.

TStyleManager.SetSystemStyle(Self);

回答1:

I added the Default_Style_Block_Pointer: TMemoryStream; to the MainForm Var: block

I placed this code in the MainForm.OnCreate event:

Default_Style_Block_Pointer:=TMemoryStream.Create;
  TStyleStreaming.SaveToStream(TStyleManager.ActiveStyle(Self),Default_Style_Block_Pointer,TStyleFormat.Binary);

I am using this code to restore the default style:

     Default_Style_Block_Pointer.Position:=0; 
        TStyleManager.SetStyle(TStyleStreaming.LoadFromStream(Default_Style_Block_Pointer));