zoukankan      html  css  js  c++  java
  • Delphi XE2使用VCL Styles (皮肤/skin)

    在新版本中,你可以直接给你的程序换皮肤/skin(主题),Project-> Options -> Application -> Appearance,在这里选一个你想要的主题,



    当然,你可以在你的程序里自己设定,为了使用VCL Styles,你需要使用TStyleManager类,Themes单元,如下几步:
    注册Style
    从文件加载(注册)VCL style,需要使用TStyleManager类中的LoadFromFile函数,

    1. procedure RegisterStyleFromDisk(const StyleFileName: string);
    2. begin
    3.   try
    4.     if TStyleManager.IsValidStyle(StyleFileName) then
    5.     TStyleManager.LoadFromFile(StyleFileName);
    6.     //beware in this line you are only loading and registering a VCL Style and not setting as the   current style.
    7.   else
    8.     ShowMessage('the Style is not valid');
    9. end;


    然后使用LoadFromResource或TryLoadFromResource从源加载style

    1. procedure RegisterStyleFromResource(const StyleResource: string);
    2. begin
    3.   TStyleManager.LoadFromResource(HInstance, StyleResource);
    4.   //beware in this line you are only loading and registering a VCL Style and not setting as the current style.
    5. end;


    设置Style
    设置已经加载好的Style,需要使用SetStyle(或TrySetStyle) procedure.
    注意:SetStyle 有3个重载版本

    1. //class procedure SetStyle(const Name: string); overload;
    2.     TStyleManager.SetStyle('StyleName');
    1. //class procedure SetStyle(Style: TCustomStyleServices); overload;
    2.     TStyleManager.SetStyle(TStyleManager.Style['StyleName']);
    1. //class procedure SetStyle(Handle: TStyleServicesHandle); overload;
    2.     TStyleManager.SetStyle(TStyleManager.LoadFromFile(StyleFileName))


    使用上面代码写的Demo

  • 相关阅读:
    GIT非常见命令使用笔记
    视频封转类
    IOS ASIFormDataRequest使用简介(2/25)
    开发中常用的宏
    数据库使用fmdb
    毕业五年决定你的命运-----值得所有不甘平庸的人看看
    关于路径的使用,assi下载和
    关于图片处理的方法整理
    iOS开发之Objective-C与JavaScript的交互(转载)
    IOS UIWebView引用外部CSS样式(转载)
  • 原文地址:https://www.cnblogs.com/drgraph/p/2338255.html
Copyright © 2011-2022 走看看