Delphi的原始窗口界面看起来并不够吸引人。尝试下载并安装第三方皮肤可能会导致应用程序尺寸急剧增加,并且可能会出现不稳定的情况。事实上,Delphi自带了皮肤功能,完全可以满足我们对窗口界面的美化需求,并且还支持动态切换皮肤。
文章目录
- 1. 最终效果图
- 2. 部分核心代码
- 3. 完整Demo源码下载
1. 最终效果图
2. 部分核心代码
function TForm1.LoadLightTheme: Boolean;
varLStyleInfo: TStyleInfo;LFilePath : string;
beginResult := False;LFilePath := GetCurrentDir + '\theme\Light.vsf';if TStyleManager.IsValidStyle(LFilePath, LStyleInfo) thenbeginif (TStyleManager.Style[LStyleInfo.Name] <> nil) then // already loaded...beginif TStyleManager.TrySetStyle(LStyleInfo.Name) then// Memo1.Lines.Add(LStyleInfo.Name + ' was defined with success!');Result := True;end else beginif not((TStyleManager.LoadFromFile(LFilePath) <> nil) and TStyleManager.TrySetStyle(LStyleInfo.Name, False)) then// Memo1.Lines.Add('It was not possible use this style = ' + LStyleInfo.Name)else// Memo1.Lines.Add(LStyleInfo.Name + ' was defined with success!');Result := True;end;endelseShowMessage('The file VSF was not valid to load it...');
end;function TForm1.LoadDarkTheme: Boolean;
varLStyleInfo: TStyleInfo;LFilePath : string;
beginResult := True;LFilePath := GetCurrentDir + '\theme\Dark.vsf';if TStyleManager.IsValidStyle(LFilePath, LStyleInfo) thenbeginif (TStyleManager.Style[LStyleInfo.Name] <> nil) then // already loaded...beginif TStyleManager.TrySetStyle(LStyleInfo.Name) then// Memo1.Lines.Add(LStyleInfo.Name + ' was defined with success!');Result := True;end else beginif not((TStyleManager.LoadFromFile(LFilePath) <> nil) and TStyleManager.TrySetStyle(LStyleInfo.Name, False)) then// Memo1.Lines.Add('It was not possible use this style = ' + LStyleInfo.Name)else// Memo1.Lines.Add(LStyleInfo.Name + ' was defined with success!');Result := True;end;endelseShowMessage('The file VSF was not valid to load it...');
end;
3. 完整Demo源码下载
来源 | 链接 |
---|---|
csdn下载: | 点击下载Demo[完整源码] |