• Inno Setup入门(二十一)——Inno Setup类参考(7)


    Install Setup 2013-02-02 11:31 378人阅读 评论(0) 收藏 举报

    复选框

    复选框(CheckBox)用于多个并不互斥的几个选项中作出一个或者多选择,例如字体可以有粗体、斜体和下划线,这三种状态可以任意组合,像这样的选项可以采用复选框实现。Pascal脚本中对应的类是TcheckBox,其定义如下:< xmlnamespace prefix ="o" ns ="urn:schemas-microsoft-com:office:office" />

    TCheckBox = class(TCustomCheckBox)

    property Alignment: TAlignment; read write;

    property AllowGrayed: Boolean; read write;

    property Caption: String; read write;

    property Checked: Boolean; read write;

    property Color: TColor; read write;

    property Font: TFont; read write;

    < xmlnamespace prefix ="st1" ns ="urn:schemas-microsoft-com:office:smarttags" />property State: TCheckBoxState; read write;

    property OnClick: TNotifyEvent; read write;

    end;

    其层次模型如下:

    该类比RadioBox多继承了一个TcustomCheckBox,这样就有了更多的功能。下面的代码将演示复选框的使用:

    [setup]

    AppName=Test

    AppVerName=TEST

    DefaultDirName="E:TEST"

    AppVersion=1.0

    [files]

    Source:zzz.iss;Flags:dontcopy

    [code]

    var

    myPage:TWizardPage;

    lbl:TLabel;

    chk1,chk2,chk3:TCheckBox;

    procedure ClickCHK1(Sender:TObject);

    begin

    if chk1.Checked then

    lbl.Font.Style:=lbl.Font.Style+[fsBold]

    else

    lbl.Font.Style:=lbl.Font.Style-[fsBold];

    end;

    procedure ClickCHK2(Sender:TObject);

    begin

    if chk2.Checked then

    lbl.Font.Style:=lbl.Font.Style+[fsItalic]

    else

    lbl.Font.Style:=lbl.Font.Style-[fsItalic];

    end;

    procedure ClickCHK3(Sender:TObject);

    begin

    if chk3.Checked then

    lbl.Font.Style:=lbl.Font.Style+[fsUnderline]

    else

    lbl.Font.Style:=lbl.Font.Style-[fsUnderline];

    end;

    procedure InitializeWizard();

    begin

    myPage:=CreateCustomPage(wpWelcome, '标题:自定义页面', '描述:这是我的自定义页面');

    lbl:=TLabel.Create(myPage);

    lbl.Parent:=myPage.Surface;

    lbl.Caption:='请选择复选框,并注意文字的变化';

    chk1:=TCheckBox.Create(myPage);

    chk1.Parent:=myPage.Surface;

    chk1.Caption:='粗体';

    chk1.top:=lbl.Top+20;

    chk1.OnClick:=@ClickCHK1;

    chk2:=TCheckBox.Create(myPage);

    chk2.Parent:=myPage.Surface;

    chk2.Caption:='斜体';

    chk2.top:=chk1.Top+20;

    chk2.OnClick:=@ClickCHK2;

    chk3:=TCheckBox.Create(myPage);

    chk3.Parent:=myPage.Surface;

    chk3.Caption:='下划线';

    chk3.top:=chk2.Top+20;

    chk3.OnClick:=@ClickCHK3;

    end;

    程序运行效果如下:

    另外复选框还有一个重要的属性就是State,该属性指定了复选框的外观,可以有三个值,分别是cbUnchecked、cbChecked和cbGrayed,即未选择、选择和未定,可以使用如下代码设定:

    chk1.State:=cbUnchecked;

    chk2.State:=cbChecked;

    chk3.State:=cbGrayed;

    效果如下:

  • 相关阅读:
    CocoaPods 安装教程
    iOS 如何使用第三方字库
    iOS 获取当前网络状态
    GitHub上README.md教程
    如何获取iOS软件包内容
    iOS中如何监测来电
    OS 如何选择delegate、notification、KVO?
    iOS-Block总结 && 全面解析逆向传值
    iOS面试题
    iOS优秀博客收录
  • 原文地址:https://www.cnblogs.com/atuo/p/4777701.html
Copyright © 2020-2023  润新知