http://www.cnblogs.com/awei0611/archive/2010/06/09.html
1 、如何让协议许可页面默认选中我同意按钮
[delphi] view plaincopyprint?
[code] procedure initializewizard(); beginwizardform.licenseacceptedradio.checked := true; end; [code]procedure initializewizard();beginwizardform.licenseacceptedradio.checked := true;end;
2、自定义安装程序右上角图片大小
[delphi] view plaincopyprint?
[code] procedure initializewizard(); beginwizardform.wizardsmallbitmapimage.width:=150; //设置页眉图片的大小 wizardform.wizardsmallbitmapimage.left:=wizardform.width-150; //设置左边页眉留出的空隙 wizardform.pagenamelabel.width:=0; //设置标题文字显示的大小 wizardform.pagedescriptionlabel.width:=0; //设置标题文字显示的大小 end; [code]procedure initializewizard();beginwizardform.wizardsmallbitmapimage.width:=150; //设置页眉图片的大小wizardform.wizardsmallbitmapimage.left:=wizardform.width-150; //设置左边页眉留出的空隙wizardform.pagenamelabel.width:=0; //设置标题文字显示的大小wizardform.pagedescriptionlabel.width:=0; //设置标题文字显示的大小end;
或者
//自定义安装向导小图片
[delphi] view plaincopyprint?
[code] procedure initializewizard(); beginwizardform.wizardsmallbitmapimage.left:= wizardform.width-164; //自定义安装向导小图片显示位置 wizardform.wizardsmallbitmapimage.width:=164; //自定义安装向导小图片宽度 wizardform.pagenamelabel.width:= 495 - 164 -36; //这儿必须定义,数值根据图片宽度更改,显示软件名称的位置 wizardform.pagedescriptionlabel.width:= 495 - 164 -42; //显示页面信息的位置 end; [code]procedure initializewizard();beginwizardform.wizardsmallbitmapimage.left:= wizardform.width-164; //自定义安装向导小图片显示位置wizardform.wizardsmallbitmapimage.width:=164; //自定义安装向导小图片宽度wizardform.pagenamelabel.width:= 495 - 164 -36; //这儿必须定义,数值根据图片宽度更改,显示软件名称的位置wizardform.pagedescriptionlabel.width:= 495 - 164 -42; //显示页面信息的位置end;
3、自定义beveledlabel显示代码
[delphi] view plaincopyprint?
[code] procedure initializewizard(); beginwizardform.beveledlabel.enabled:=true; //允许显示 wizardform.beveledlabel.font.color:=$00058451;; //显示颜色 wizardform.beveledlabel.font.style := wizardform.beveledlabel.font.style + [fsbold]; //显示字体 wizardform.beveledlabel.left:=5; //显示位置 end; [code]procedure initializewizard();beginwizardform.beveledlabel.enabled:=true; //允许显示wizardform.beveledlabel.font.color:=$00058451;; //显示颜色wizardform.beveledlabel.font.style := wizardform.beveledlabel.font.style + [fsbold]; //显示字体wizardform.beveledlabel.left:=5; //显示位置end;
4、自定义安装向导图片
[delphi] view plaincopyprint?
[code] procedure initializewizard(); beginwizardform.welcomelabel1.left:= 18; //自定义欢迎页面标题1显示位置 wizardform.welcomelabel2.left:= 18; //自定义欢迎页面标题2显示位置 wizardform.wizardbitmapimage.left:= wizardform.width-164//自定义安装向导图片显示位置(显示大小,此处为居右显示) end; [code]procedure initializewizard();beginwizardform.welcomelabel1.left:= 18; //自定义欢迎页面标题1显示位置wizardform.welcomelabel2.left:= 18; //自定义欢迎页面标题2显示位置wizardform.wizardbitmapimage.left:= wizardform.width-164 //自定义安装向导图片显示位置(显示大小,此处为居右显示)end;
5、显示出组件选择框 [types]
[delphi] view plaincopyprint?
name: full; description: 推荐 name: default; description: 典型 name: custom; description: 自定义; flags: iscustom ;告诉安装程序这个类型是自定义类型。必须定义iscustom这个参数,才能显示出组件选择框 name: full; description: 推荐name: default; description: 典型name: custom; description: 自定义; flags: iscustom;告诉安装程序这个类型是自定义类型。必须定义iscustom这个参数,才能显示出组件选择框
6、定义[messages]的颜色
[delphi] view plaincopyprint?
[code] procedure initializewizard(); beginwizardform.beveledlabel.enabled:= true; wizardform.beveledlabel.font.color:= clblue; end; [code]procedure initializewizard();beginwizardform.beveledlabel.enabled:= true;wizardform.beveledlabel.font.color:= clblue;end;
7、不显示一些特定的安装界面
[delphi] view plaincopyprint?
[code] function shouldskippage(pageid: integer): boolean; beginif pageid=wpready thenresult := true; end; (* wpready 是准备安装界面 pageid查询 inno帮助中的 pascal 脚本: 事件函数常量 预定义向导页 curpageid 值 wpwelcome, wplicense, wppassword, wpinfobefore, wpuserinfo, wpselectdir, wpselectcomponents, wpselectprogramgroup, wpselecttasks, wpready, wppreparing, wpinstalling, wpinfoafter, wpfinished [code]function shouldskippage(pageid: integer): boolean; begin if pageid=wpready then result := true; 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、在运行卸载程序前显示弹出式消息
[delphi] view plaincopyprint?
[code] function initializeuninstall(): boolean; beginif msgbox('', mbconfirmation, mb_yesno) = idyes thenresult:=trueelseresult:=false; end; [code]function initializeuninstall(): boolean;beginif msgbox('', mbconfirmation, mb_yesno) = idyes thenresult:=trueelseresult:=false;end;
12、安装、卸载时判断是否程序正在运行,卸载完成时自动打开网页
[delphi] view plaincopyprint?
[code] varerrorcode: integer; isrunning: integer; // 安装时判断客户端是否正在运行 function initializesetup(): boolean; beginresult :=true; //安装程序继续 isrunning:=findwindowbywindowname('东方宽频网络电视'); while isrunning0dobeginif msgbox('安装程序检测到客户端正在运行。' #13#13'您必须先关闭它然后单击“是”继续安装,或按“否”退出!', mbconfirmation, mb_yesno) = idno thenbeginresult :=false; //安装程序退出 isrunning :=0; endelsebeginresult :=true; //安装程序继续 isrunning:=findwindowbywindowname('东方宽频网络电视'); end; end; end; // 卸载时判断客户端是否正在运行 function initializeuninstall(): boolean; beginresult :=true; //安装程序继续 isrunning:=findwindowbywindowname('东方宽频网络电视'); while isrunning0dobeginif msgbox('安装程序检测到客户端正在运行。' #13#13'您必须先关闭它然后单击“是”继续安装,或按“否”退出!', mbconfirmation, mb_yesno) = idno thenbeginresult :=false; //安装程序退出 isrunning :=0; endelsebeginresult :=true; //安装程序继续 isrunning:=findwindowbywindowname('东方宽频网络电视'); end; end; end; procedure curuninstallstepchanged(curuninstallstep: tuninstallstep); begincase curuninstallstep ofusuninstall: begin// 开始卸载 end; uspostuninstall: begin// 卸载完成 // msgbox('curuninstallstepchanged:' #13#13 'uninstall just finished.', mbinformation, mb_ok); // ...insert code to perform post-uninstall tasks here... shellexec('open', 'http://www.dreams8.com', '', '', sw_shownormal, ewnowait, errorcode); end; end; end; [code]varerrorcode: integer;isrunning: integer;// 安装时判断客户端是否正在运行 function initializesetup(): boolean; begin result :=true; //安装程序继续 isrunning:=findwindowbywindowname('东方宽频网络电视'); while isrunning0 do begin if msgbox('安装程序检测到客户端正在运行。' #13#13 '您必须先关闭它然后单击“是”继续安装,或按“否”退出!', mbconfirmation, mb_yesno) = idno then begin result :=false; //安装程序退出 isrunning :=0; end else begin result :=true; //安装程序继续 isrunning:=findwindowbywindowname('东方宽频网络电视'); end; end; end; // 卸载时判断客户端是否正在运行 function initializeuninstall(): boolean; begin result :=true; //安装程序继续 isrunning:=findwindowbywindowname('东方宽频网络电视'); while isrunning0 do begin if msgbox('安装程序检测到客户端正在运行。' #13#13 '您必须先关闭它然后单击“是”继续安装,或按“否”退出!', mbconfirmation, mb_yesno) = idno then begin result :=false; //安装程序退出 isrunning :=0; end else begin result :=true; //安装程序继续 isrunning:=findwindowbywindowname('东方宽频网络电视'); end; end; end; procedure curuninstallstepchanged(curuninstallstep: tuninstallstep); begin case curuninstallstep of usuninstall: begin // 开始卸载 end; uspostuninstall: begin // 卸载完成 // msgbox('curuninstallstepchanged:' #13#13 'uninstall just finished.', mbinformation, mb_ok); // ...insert code to perform post-uninstall tasks here... shellexec('open', 'http://www.dreams8.com', '', '', sw_shownormal, ewnowait, errorcode); end; end; end;
13、 删除文件和删除文件夹
[delphi] view plaincopyprint?
//删除文件 用 deletefile 只能删除一个文件,不能使用通配符来删除多个文件 deletefile(expandconstant('{app}\abc.exe')); //删除所有文件及文件夹 deltree(expandconstant('{app}'), true, true, false); //删除文件 用 deletefile 只能删除一个文件,不能使用通配符来删除多个文件deletefile(expandconstant('{app}\abc.exe'));//删除所有文件及文件夹deltree(expandconstant('{app}'), true, true, false);
14、borderstyle
tformborderstyle = (bsnone, bssingle, bssizeable, bsdialog, bstoolwindow, bssizetoolwin);
无边界式(bsnone) ,单边固定式(bssingle),双边可变式(bssizeable),对话框式(bsdialog)
15、if else
[delphi] view plaincopyprint?
function nextbuttonclick(curpageid: integer): boolean; varresultcode: integer; beginresult := true; if (curpageid = wpselectdir) thenbeginmsgbox('aaaa', mbinformation, mb_ok); endelsebeginmsgbox('bbbb', mbinformation, mb_ok); end; end; function nextbuttonclick(curpageid: integer): boolean; var resultcode: integer; begin result := true; if (curpageid = wpselectdir) then begin msgbox('aaaa', mbinformation, mb_ok); end else begin msgbox('bbbb', mbinformation, mb_ok); end; end;
16、安装结束界面增加“设为首页”选项
[delphi] view plaincopyprint?
[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[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、添加“关于”和网站链接按钮
[delphi] view plaincopyprint?
[code] procedure urllabelonclick(sender: tobject); varerrorcode: integer; beginshellexec('open', 'http://www.vistaqq.com', '', '', sw_shownormal, ewnowait, errorcode); end; procedure aboutbuttononclick(sender: tobject); beginmsgbox(#13'vista 状态条风格盘符' #13 #13'本软件由jinn制作,希望各位登陆中天vip工作室!' #13#13, mbinformation, mb_ok); end; varaboutbutton, 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、去掉安装程序左上角“关于安装程序”的代码
[delphi] view plaincopyprint?
procedure initializewizard(); beginwizardform.bordericons:= [biminimize]; end; procedure curpagechanged(curpage: integer); beginif curpage=wpwelcome thenwizardform.bordericons:= [bisystemmenu, biminimize]; end; 或者 procedure initializewizard(); beginwizardform.bordericons := [bihelp, bisystemmenu, biminimize]; end; procedure initializewizard();beginwizardform.bordericons:= [biminimize];end;procedure curpagechanged(curpage: integer);beginif curpage=wpwelcome thenwizardform.bordericons:= [bisystemmenu, biminimize];end;或者procedure initializewizard();beginwizardform.bordericons := [bihelp, bisystemmenu, biminimize];end;
19、自定义beveledlabel文字
[messages]
beveledlabel=中天vip工作室
20、自定义安装程序界面左上角“安装”文字
[message]
setupapptitle=需要的字
setupwindowtitle=需要的字
21、自定义安装程序版本号
versioninfoversion=1.1
versioninfotextversion=1.1
