QQ群大神大悟还俗发现fpcudeluxe在windows能实现暗黑模式,从fpcupdeluxe提取相关代码后,用lazarus编写的应用也可以实现暗黑模式。
实现暗黑模式的步骤:
1、拷贝fpcudeluxe的metadarkstyle文件夹的文件到project目录(已将metadarkstyle打包,下载地址:https://www.123pan.com/s/6OFxjv-JFdu3?提取码:iBiZ)
2、打开project文件(*.lpr)的uses增加下图绿框的代码
program Project1; {$mode objfpc}{$H+} uses {$IFDEF UNIX} cthreads, {$ENDIF} {$IFDEF HASAMIGA} athreads, {$ENDIF} {$ifdef LCL} {$ifdef windows} uMetaDarkStyle, uDarkStyleSchemes, uDarkStyleParams, {$endif} {$endif} Interfaces, // this includes the LCL widgetset Forms, unit1 { you can add units after this }; {$R *.res} begin {$ifdef windows} PreferredAppMode:= pamAllowDark; uMetaDarkStyle.ApplyMetaDarkStyle(DefaultDark); {$endif} Application.Scaled:=True; Application.Initialize; Application.CreateForm(TForm1, Form1); Application.Run; end.
编译后的应用在windows暗黑模式: