zoukankan      html  css  js  c++  java
  • Inno 常用[code]修改技巧

    转自:http://www.dreams8.com/thread-6595-1-1.html

    因时间问题,代码格式没有整理,请谅解。

    正文:

    记录一下自己在学习inno时候遇到的一些问题,以及涉及到code段代码问题,方便自己和大家查找解决问题。 

    1 、如何让协议许可页面默认选中我同意按钮

    1. [code]
    2. procedure InitializeWizard();
    3. begin
    4. WizardForm.LICENSEACCEPTEDRADIO.Checked := true;
    5. end;
    复制代码

    2、自定义安装程序右上角图片大小

    1. [code]
    2. procedure InitializeWizard();
    3. begin
    4. WizardForm.WizardSmallBitmapImage.=150; //设置页眉图片的大小
    5. WizardForm.WizardSmallBitmapImage.left:=WizardForm.width-150; //设置左边页眉留出的空隙
    6. WizardForm.PAGENAMELABEL.=0; //设置标题文字显示的大小
    7. WizardForm.PAGEDESCRIPTIONLABEL.=0; //设置标题文字显示的大小
    8. end;
    复制代码

    或者

    //自定义安装向导小图片

    1. [code]
    2. procedure InitializeWizard();
    3. begin
    4. Wizardform.WizardSmallBitmapImage.left:= WizardForm.width-164; //自定义安装向导小图片显示位置
    5. WizardForm.WizardSmallBitmapImage.=164; //自定义安装向导小图片宽度
    6. Wizardform.PageNameLabel.= 495 - 164 -36; //这儿必须定义,数值根据图片宽度更改,显示软件名称的位置
    7. Wizardform.PageDescriptionLabel.= 495 - 164 -42; //显示页面信息的位置
    8. end;
    复制代码

    3、自定义BeveledLabel示代码

    1. [code]
    2. procedure InitializeWizard();
    3. begin
    4. WizardForm.BeveledLabel.Enabled:=true; //充许显示
    5. WizardForm.BeveledLabel.Font.Color:=$00058451;; //显示颜色
    6. WizardForm.BeveledLabel.Font.Style := WizardForm.BeveledLabel.Font.Style + [fsBold]; //显示字体
    7. WizardForm.BeveledLabel.Left:=5; //显示位置
    8. end;
    复制代码

    4、自定义安装向导图片

    1. [code]
    2. procedure InitializeWizard();
    3. begin
    4. Wizardform.WELCOMELABEL1.left:= 18; //自定义欢迎页面标题1显示位置
    5. Wizardform.WELCOMELABEL2.left:= 18; //自定义欢迎页面标题2显示位置
    6. Wizardform.WizardBitmapImage.left:= WizardForm.width-164 //自定义安装向导图片显示位置(显示大小,此处为居右显示)
    7. end;
    复制代码

    5、显示出组件选择框

    1. [Types]
    2. Name: full; Description: 推荐
    3. Name: default; Description: 典型
    4. Name: custom; Description: 自定义; Flags: iscustom
    5. ;告诉安装程序这个类型是自定义类型。必须定义iscustom这个参数,才能显示出组件选择框
    复制代码

    6、定义[Messages]的颜色

    1. [code]
    2. procedure InitializeWizard();
    3. begin
    4. WizardForm.BeveledLabel.Enabled:= True;
    5. WizardForm.BeveledLabel.Font.Color:= clblue;
    6. end;
    复制代码

    7、不显示一些特定的安装界面

    1. [code]
    2. function ShouldSkipPage(PageID: Integer): Boolean; 
    3. begin 
    4. if PageID=wpReady then 
    5. result := true; 
    6. end;
    复制代码

    wpReady  是 准备安装界面
    PageID查询 INNO帮助中的 Pascal 脚本: 事件函数   常量

    预定义向导页 CurPageID 值
    wpWelcome, wpLicense, wpPassword, wpInfoBefore, wpUserInfo, wpSelectDir, wpSelectComponents, wpSelectProgramGroup, wpSelectTasks, wpReady, wpPreparing, wpInstalling, wpInfoAfter, wpFinished

    8、换行符号

    在  [Messages]   换行符号为%n
    在  MsgBox  中换行符号为 #13#10    //#13 为回车字符

    9、颜色代码

    (1)一个值形如 $bbggrr, 这里的 rr, gg 和 bb 指定了两位的亮度值(以十六进制表示)分别为红色,绿色和蓝色。

    (2)预定义的颜色名称:

    clBlack(黑色),clMaroon(暗红),clGreen(绿色),clOlive(橄榄绿),
    clNavy(深蓝),clPurple(紫色),clTeal(深青),clGray(灰色),
    clSilver(浅灰),clRed(红色),clLime(浅绿),clYellow(黄色),
    clBlue(蓝色),clFuchsia(紫红),clAqua(青绿),clWhite(白色)。

    10、inno代码注释符号

    ;      实例 ——   ; 分号 
    //     实例 ——  // 双斜杠  多用在code段
    { }    实例 —— {大括号    多用在code段}

    注释符号均在英文输入法状态下输入

    11、在运行卸载程序前显示弹出式消息

    1. [code]
    2. function InitializeUninstall(): Boolean;
    3. begin
    4. if MsgBox('', mbConfirmation, MB_YESNO) = IDYES then
    5. result:=true
    6. else
    7. result:=false;
    8. end;
    复制代码

    12、安装、卸载时判断是否程序正在运行,卸载完成时自动打开网页

    1. [code]
    2. var
    3.   ErrorCode: Integer;
    4.   IsRunning: Integer;
    5. // 安装时判断客户端是否正在运行   
    6.   
    7. function InitializeSetup(): Boolean;   
    8.   
    9. begin   
    10.   
    11.   Result :=true;  //安装程序继续   
    12.   
    13.   IsRunning:=FindWindowByWindowName('东方宽频网络电视');   
    14.   
    15.   while IsRunning<>0 do  
    16.   
    17.   begin   
    18.   
    19.     if Msgbox('安装程序检测到客户端正在运行。'  #13#13 '您必须先关闭它然后单击“是”继续安装,或按“否”退出!', mbConfirmation, MB_YESNO) = idNO then   
    20.   
    21.     begin   
    22.   
    23.       Result :=false; //安装程序退出   
    24.   
    25.       IsRunning :=0;   
    26.   
    27.     end else begin   
    28.   
    29.       Result :=true;  //安装程序继续   
    30.   
    31.       IsRunning:=FindWindowByWindowName('东方宽频网络电视');   
    32.   
    33.     end;   
    34.   
    35.   end;   
    36.    
    37. end;   
    38.   
    39.   
    40.   
    41. // 卸载时判断客户端是否正在运行   
    42.   
    43. function InitializeUninstall(): Boolean;   
    44.   
    45. begin   
    46.   
    47.    Result :=true;  //安装程序继续   
    48.   
    49.   IsRunning:=FindWindowByWindowName('东方宽频网络电视');   
    50.   
    51.   while IsRunning<>0 do  
    52.   
    53.   begin   
    54.   
    55.     if Msgbox('安装程序检测到客户端正在运行。'  #13#13 '您必须先关闭它然后单击“是”继续安装,或按“否”退出!', mbConfirmation, MB_YESNO) = idNO then   
    56.   
    57.     begin   
    58.   
    59.       Result :=false; //安装程序退出   
    60.   
    61.       IsRunning :=0;   
    62.   
    63.     end else begin   
    64.   
    65.       Result :=true;  //安装程序继续   
    66.   
    67.       IsRunning:=FindWindowByWindowName('东方宽频网络电视');   
    68.   
    69.     end;   
    70.   
    71.   end;   
    72.   
    73. end;   
    74.   
    75.   
    76.   
    77. procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);   
    78.   
    79. begin   
    80.   
    81.   case CurUninstallStep of   
    82.   
    83.     usUninstall:   
    84.   
    85.       begin // 开始卸载   
    86.     
    87.       end;   
    88.   
    89.     usPostUninstall:   
    90.   
    91.       begin      // 卸载完成   
    92.   
    93.         // MsgBox('CurUninstallStepChanged:' #13#13 'Uninstall just finished.', mbInformation, MB_OK);   
    94.   
    95.         // ...insert code to perform post-uninstall tasks here...   
    96.   
    97.         ShellExec('open', 'http://www.dreams8.com', '', '', SW_SHOWNORMAL, ewNoWait, ErrorCode);   
    98.   
    99.       end;   
    100.   
    101.   end;   
    102.   
    103. end;  
    104.   
    复制代码

    13、 删除文件和删除文件夹

    1. //删除文件    用 DeleteFile 只能删除一个文件,不能使用通配符来删除多个文件
    2. DeleteFile(ExpandConstant('{app}\abc.exe'));
    3. //删除所有文件及文件夹
    4. DelTree(ExpandConstant('{app}'), True, True, False);
    复制代码

    14、BorderStyle

    TFormBorderStyle = (bsNone, bsSingle, bsSizeable, bsDialog, bsToolWindow, bsSizeToolWin);

    无边界式(bsNone)  ,单边固定式(bsSingle),双边可变式(bsSizeable),对话框式(bsDialog)

    15、if   else

    1. function NextButtonClick(CurPageID: Integer): Boolean; 
    2. var 
    3.   ResultCode: Integer; 
    4. begin 
    5.   Result := True; 
    6.   if (CurPageID = wpSelectDir) then 
    7.   begin 
    8.   MsgBox('AAAA', mbInformation, MB_OK); 
    9.   end 
    10.   else 
    11.   begin 
    12.   MsgBox('BBBB', mbInformation, MB_OK); 
    13.   end; 
    14. end;
    复制代码


    16、安装结束界面增加“设为首页”选项
    [Tasks]
    Name: changestartpage; Description: "设置vistaqq为默认主页"
    [Registry]
    Root: HKCU; Subkey: "Software\Microsoft\Internet Explorer\Main"; ValueType: string; ValueName: "Start Page"; ValueData: "http://www.vistaqq.com"; tasks: changestartpage
    17、添加“关于”和网站链接按钮
    [Code]
    procedure URLLabelOnClick(Sender: TObject);
    var
    ErrorCode: Integer;
    begin
    ShellExec('open', 'http://www.vistaqq.com', '', '', SW_SHOWNORMAL, ewNoWait, ErrorCode);
    end;
    procedure AboutButtonOnClick(Sender: TObject);
    begin
    MsgBox(#13 'Vista 状态条风格盘符' #13 #13'本软件由jinn制作,希望各位登陆中天VIP工作室!' #13#13 '版权所有 (C) 中天VIP工作室', mbInformation, MB_OK);
    end;
    var
        AboutButton, CancelButton: TButton;
        URLLabel: TNewStaticText;
    procedure InitializeWizard();
    begin
    { Create the pages }
    WizardForm.PAGENAMELABEL.Font.Color:= clred;
    WizardForm.PAGEDESCRIPTIONLABEL.Font.Color:= clBlue;
    WizardForm.WELCOMELABEL1.Font.Color:= clGreen;
    WizardForm.WELCOMELABEL2.Font.Color:= clblack;
       CancelButton := WizardForm.CancelButton;
         AboutButton := TButton.Create(WizardForm);
         AboutButton.Left := WizardForm.ClientWidth - CancelButton.Left - CancelButton.Width;
         AboutButton.Top := CancelButton.Top;
         AboutButton.Width := CancelButton.Width;
         AboutButton.Height := CancelButton.Height;
         AboutButton.Caption := '&About';
         AboutButton.OnClick := @AboutButtonOnClick;
         AboutButton.Parent := WizardForm;
    URLLabel := TNewStaticText.Create(WizardForm);
        URLLabel.Caption := '中天VIP工作室';
        URLLabel.Cursor := crHand;
        URLLabel.OnClick := @URLLabelOnClick;
        URLLabel.Parent := WizardForm;
        { Alter Font *after* setting Parent so the correct defaults are inherited first }
        URLLabel.Font.Style := URLLabel.Font.Style + [fsUnderline];
        URLLabel.Font.Color := clBlue;
        URLLabel.Top := AboutButton.Top + AboutButton.Height - URLLabel.Height - 2;
        URLLabel.Left := AboutButton.Left + AboutButton.Width + ScaleX(20);
    end;
    18、去掉安装程序左上角“关于安装程序”的代码
    procedure InitializeWizard();
    begin
    WizardForm.BorderIcons:= [biMinimize];
    end;
    procedure CurPageChanged(CurPage: Integer);
    begin
    if CurPage=wpWelcome then
    WizardForm.BorderIcons:= [biSystemMenu, biMinimize];
    end;
    或者
    procedure InitializeWizard();
    begin
    WizardForm.BORDERICONS := [biHelp, biSystemMenu, biMinimize];
    end;
    19、自定义BeveledLabel文字
    [Messages]
    BeveledLabel=中天VIP工作室
    20、自定义安装程序界面左上角“安装”文字
    [message]
    SetupAppTitle=需要的字
    SetupWindowTitle=需要的字
    21、自定义安装程序版本号
    VersionInfoVersion=1.1
    VersionInfoTextVersion=1.1

  • 相关阅读:
    Mongodb
    Java原子类
    volatile
    uniapp输入空格
    看不见的的html
    小程序隐藏scroll-view滚动条的方法
    云函数调用云函数 openid不存在
    vue路由中 Navigating to current location ("/xxx") is not allowed
    Vue: 单页面应用如何保持登录状态
    letter-spacing
  • 原文地址:https://www.cnblogs.com/xiurui12345/p/3099552.html
Copyright © 2011-2022 走看看