码迷,mamicode.com
首页 > 其他好文 > 详细

一个相对完整的inno setup

时间:2016-06-24 16:04:05      阅读:449      评论:0      收藏:0      [点我收藏+]

标签:

代码:

;#define MyAppId "{{01DDF602-7CF8-40C9-816F-AD165F37F5E0}"
#define MyAppName "ABCD"
#define MyAppVersion "1.0.1.2"
#define MyAppPublisher "AAA股份有限公司"
#define MyAppURL "http://www.AAAA.com.cn/"
#define MyAppExeName "AAAA.exe"

#include "trayiconctrl.iss"

[Setup]
AppId={{01DDF602-7CF8-40C9-816F-AD165F37F5E0}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
AppVerName={#MyAppName}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
DefaultDirName={pf}\Julong Educational\SCEngine
DefaultGroupName={#MyAppName}
AllowNoIcons=yes
OutputDir=D:OutputBaseFilename=SCEngine setup
SetupIconFile=installer.ico
Compression=lzma/ultra64
SolidCompression=yes
VersionInfoVersion={#MyAppVersion}
VersionInfoTextVersion={#MyAppVersion}
VersionInfoDescription=SCEngine setup
DisableReadyPage=yes
DisableProgramGroupPage=yes
InternalCompressLevel=ultra64
DirExistsWarning=no
UninstallIconFile=Uninstall.ico

[Messages]
BeveledLabel=


[CustomMessages]
FinishedHeadingLabel=恭喜你,{#MyAppName}安装成功!
FinishedLabel=安装程序已在您的电脑中安装了“{#MyAppName}”。此应用程序可以通过选择安装的快捷方式运行。%n%n单击 [完成(F)] 关闭安装程序。
Tooltip={#MyAppName} Ver 1.0
TooltipText={#MyAppName}安装正在开始...
MenuStrs=显示/隐藏  {#MyAppName} 安装程序;-;关于 {#MyAppName} ;-;退出 {#MyAppName} 安装


[Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"  ; WorkingDir: {app};Check: groupicon
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"; WorkingDir: {app}; Check: groupicon
Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}";  WorkingDir: {app};Check: desktopicon
;Name: {userappdata}\Microsoft\Internet Explorer\Quick Launch\{#MyAppName}; Filename: {app}\julongEngine.exe; Check: quicklaunchicon; WorkingDir: {app}


[Files]
Source: window.bmp; DestDir: {tmp}; Flags: dontcopy solidbreak
Source: window2.bmp; DestDir: {tmp}; Flags: dontcopy solidbreak
Source: Close1.bmp; Flags: dontcopy solidbreak
Source: Close2.bmp; Flags: dontcopy solidbreak
Source: Close3.bmp; Flags: dontcopy solidbreak
Source: btnIn1.bmp; DestDir: {tmp}; Flags: dontcopy solidbreak
Source: btnIn2.bmp; DestDir: {tmp}; Flags: dontcopy solidbreak
Source: btnIn3.bmp; DestDir: {tmp}; Flags: dontcopy solidbreak


Source: "D:\SCEngine Software V1.0 Packet Ver1.0.1.2\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs; BeforeInstall: AddToDetaList; AfterInstall: Progress();
Source: "installer.ico"; Flags: dontcopy
//新增按键
Source: DirImg.bmp; DestDir: {tmp}; Flags: dontcopy solidbreak
Source: btn_by1.bmp; DestDir: {tmp}; Flags: dontcopy solidbreak
Source: btn_by2.bmp; DestDir: {tmp}; Flags: dontcopy solidbreak
Source: btn_by3.bmp; DestDir: {tmp}; Flags: dontcopy solidbreak
Source: btn_n1.bmp; DestDir: {tmp}; Flags: dontcopy solidbreak
Source: btn_n2.bmp; DestDir: {tmp}; Flags: dontcopy solidbreak
Source: btn_n3.bmp; DestDir: {tmp}; Flags: dontcopy solidbreak
Source: btn_ss1.bmp; DestDir: {tmp}; Flags: dontcopy solidbreak
Source: btn_ss2.bmp; DestDir: {tmp}; Flags: dontcopy solidbreak
Source: btn_ss3.bmp; DestDir: {tmp}; Flags: dontcopy solidbreak
Source: backBtn1.bmp; DestDir: {tmp}; Flags: dontcopy solidbreak
Source: backBtn2.bmp; DestDir: {tmp}; Flags: dontcopy solidbreak
Source: backBtn3.bmp; DestDir: {tmp}; Flags: dontcopy solidbreak




[Registry]
Root: HKCU; Subkey: "Software\Microsoft\SCEngine"; valueType: string; valueName: "path" ; valueData: """{app}\{#MyAppExeName}""";Flags: uninsdeletevalue;




[Code]
Const
  WM_SYSCOMMAND = $0112;
  WM_USER = $400;
  WM_ICON_NOTIFY = WM_USER + 22; // 自己定义一个 TrayIcon 的消息标志以和其他的消息区分
  MF_BYPOSITION = $400;
  MF_ENABLED = 0;
  MF_GRAYED = 1;
  IMAGE_ICON = 1;
  LR_LOADFROMFILE = $10;
function ReleaseCapture(): Longint; external 'ReleaseCapture@user32.dll stdcall';
function EnableMenuItem(hMenu: UINT; uIDEnableItem, uEnable: UINT): BOOL; external 'EnableMenuItem@user32.dll stdcall';
function IsWindowEnabled(hWnd: HWND): BOOL; external 'IsWindowEnabled@user32.dll stdcall';
function LoadImage(hInst: UINT; ImageName: String; ImageType: UINT; X, Y: Integer; Flags: UINT): THandle; external 'LoadImageA@user32.dll stdcall';
var
Ico: UINT;
MySetupForm: TSetupForm;
TaskBox1,TaskBox2,TaskBox3,RunBox1,RunBox2,RunBox3,RunBox4: TCheckBox;  //创建目录页面选框和新页面复选框
TaskBox1Label,TaskBox2Label,TaskBox3Label,TaskBox4Label,TaskBox5Label,TaskBox6Label,NewLabel,NewStatusLabel,FinishedLabel3,FinishedLabel4,RunBox1Label,RunBox2Label,RunBox3Label,RunBox4Label: TLabel;  //请选择安装目录


sversion,bigLabel:Tlabel;
//关闭按钮
CloseBtn: TBitmapImage;
//安装百分比
ProgressLabel: TLabel;
//安装细节
DetaList: TNewListBox;
ShowDetaBtn: TNewButton;
//按钮
NewDirEdit,setbtn,setbcbtn:Tlabel;
NextButton: TBitmapImage;
F: String;
WizardFormImage: TBitmapImage;
//目录浏览框
dirviewImage: TBitmapImage;
//选择目录
dirCooseImage: TBitmapImage;
//自定义安装
zdyianZhuangImage: TBitmapImage; 
//快速安装
ksuanZhuangImage: TBitmapImage;
//返回
backBtn: TBitmapImage;


procedure BitmapImage1MouseLeave(Sender: TObject); forward;
procedure en(Sender: TObject); forward;




//安装细节
procedure ShowDetaBtnOnClick(Sender: TObject);
begin
ShowDetaBtn.Visible := False;
DetaList.Visible := True;
end;
//单击“取消”直接退出
procedure CancelButtonClick(CurPageID: Integer; var Cancel, Confirm: Boolean);
begin
  Confirm := False;
end;


//关闭按钮
procedure CloseBtnOnMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X: Integer; Y: Integer);
begin
  CloseBtn.Bitmap.LoadFromFile(ExpandConstant('{tmp}\Close3.bmp'));
end;


procedure CloseBtnOnMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X: Integer; Y: Integer);
begin
  CloseBtn.Bitmap.LoadFromFile(ExpandConstant('{tmp}\Close2.bmp'));
end;


procedure CloseBtnOnMouseEnter(Sender: TObject);
begin
  CloseBtn.Bitmap.LoadFromFile(ExpandConstant('{tmp}\Close2.bmp'))
end;


procedure CloseBtnOnMouseLeave(Sender: TObject);
begin
  CloseBtn.Bitmap.LoadFromFile(ExpandConstant('{tmp}\Close1.bmp'));
end;


procedure CloseBtnOnClick(Sender: TObject);
begin
WizardForm.Close;
end;
//打开网站
//procedure baiduclick(Sender: TObject);
//begin
//ShellExec('open', 'http://www.baidu.com/', '', '', SW_SHOWNORMAL, ewNoWait, ErrorCode);
//end;
//procedure tbclick(Sender: TObject);
//begin
//ShellExec('open', 'http://www.taobao.com/', '', '', SW_SHOWNORMAL, ewNoWait, ErrorCode);
//end;


procedure setting(Sender: TObject);
begin
NextButton.Parent := WizardForm;
//setbcbtn.show
//setbtn.hide
NewLabel.hide
bigLabel.show
sversion.show
TaskBox1.show
//TaskBox2.show
TaskBox3.show
NewDirEdit.hide
TaskBox1Label.show
backBtn.Parent := WizardForm;
NewLabel.Caption := ExpandConstant('安装目录:');  //控件文字  '#13'
NewDirEdit.Caption:=WizardForm.DirEdit.Text;
if (Length(WizardForm.DirEdit.Text)>48) then
begin
    NewDirEdit.Caption:= Copy(WizardForm.DirEdit.Text,0,23)  + '...' +  Copy(WizardForm.DirEdit.Text,Length(WizardForm.DirEdit.Text)-20,20);
end;
TaskBox3Label.show
NewDirEdit.show
dirviewImage.show
NewLabel.show
NextButton.show
dirCooseImage.show
NewLabel.show
NewDirEdit.Show;
zdyianZhuangImage.Hide;
ksuanZhuangImage.Hide;
backBtn.Show;
WizardFormImage.Bitmap.LoadFromFile(ExpandConstant('{tmp}\window2.bmp'));
end;
//返回
procedure settingbcbtn(Sender: TObject);
begin
NextButton.show
//setbcbtn.hide
//setbtn.show
sversion.show
TaskBox1.hide
//TaskBox2.hide
TaskBox3.hide
TaskBox1Label.hide
//TaskBox2Label.hide
TaskBox3Label.hide
NextButton.hide;
dirviewImage.Hide;
NewLabel.hide;
NextButton.Hide;
dirCooseImage.Hide;
NewLabel.Hide;
NewDirEdit.hide;
zdyianZhuangImage.Show;
ksuanZhuangImage.Show;
backBtn.Hide;
WizardFormImage.Bitmap.LoadFromFile(ExpandConstant('{tmp}\window.bmp'));
end;
//浏览
procedure NewDirBrowseButtonClick(Sender: TObject);
begin
  WizardForm.DirBrowseButton.Click;
  NewDirEdit.Caption:=WizardForm.DirEdit.Text;
  if (Length(WizardForm.DirEdit.Text)>48) then
  begin
      NewDirEdit.Caption:= Copy(WizardForm.DirEdit.Text,0,23)  + '...' +  Copy(WizardForm.DirEdit.Text,Length(WizardForm.DirEdit.Text)-20,20);
  end;
end;


procedure TaskBox1LabelOnClick(Sender: TObject);
begin
if TaskBox1.Checked = False then
   TaskBox1.Checked := True
   else
   TaskBox1.Checked := False;
end;


procedure TaskBox2LabelOnClick(Sender: TObject);
begin
if TaskBox2.Checked = False then
   TaskBox2.Checked := True
   else
   TaskBox2.Checked := False;
end;


procedure TaskBox3LabelOnClick(Sender: TObject);
begin
if TaskBox3.Checked = False then
   TaskBox3.Checked := True
   else
   TaskBox3.Checked := False;
end;


procedure RunBox1LabelOnClick(Sender: TObject);
begin
if RunBox1.Checked = False then
   RunBox1.Checked := True
   else
   RunBox1.Checked := False;
end;


procedure RunBox2LabelOnClick(Sender: TObject);
begin
if RunBox2.Checked = False then
   RunBox2.Checked := True
   else
   RunBox2.Checked := False;
end;
procedure WizardFormMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  ReleaseCapture
  SendMessage(WizardForm.Handle, WM_SYSCOMMAND, $F012, 0)
end;
//系统托盘
procedure TrayMenuItemOnClick(MenuItemIndex: Integer);
begin
// 下面 这句代码表示 WizardForm 有弹出对话框时禁止菜单点击事件
if not IsWindowEnabled(WizardForm.Handle) then exit;


Case MenuItemIndex of
  0: ToggleWizardVisible; // 因为 0 项菜单为默认菜单, 所以这里的事件除了菜单点击外, 双击图标也能触发.
  2: MainForm.ShowAboutBox;
  4: WizardForm.Close;
end;
end;


procedure TrayMenuOnPopup(PopMenu: LongWord; var bShow: Boolean);
begin
// 下面这一句的效果是如果 WizardForm 显示了对话框后,为了防止多重显示对话框,所以禁止了右键菜单
bShow := IsWindowEnabled(WizardForm.Handle);
// 这里是菜单弹出前的处理回调函数, 以下的作用是当 WziardForm 缩到托盘区的时候, 禁用 "About" 和 "Exit" 的菜单
if WizardFormInTray() then
begin
  EnableMenuItem(PopMenu, 2, MF_BYPOSITION or MF_GRAYED);
  EnableMenuItem(PopMenu, 4, MF_BYPOSITION or MF_GRAYED);
end else begin
  EnableMenuItem(PopMenu, 2, MF_BYPOSITION or MF_GRAYED);
  EnableMenuItem(PopMenu, 4, MF_BYPOSITION or MF_ENABLED);
end;
end;


 //安装按键
procedure en(Sender: TObject);
begin
WizardForm.NextButton.Click;
end;


procedure fdown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X: Integer; Y: Integer);
begin
  F:= ExpandConstant('{tmp}\btnIn3.bmp');
  NextButton.Bitmap.LoadFromFile(F);
end;
procedure fup(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X: Integer; Y: Integer);
begin
  F:= ExpandConstant('{tmp}\btnIn2.bmp');
  NextButton.Bitmap.LoadFromFile(F);
end;
procedure fs(Sender: TObject);
begin
  F:= ExpandConstant('{tmp}\btnIn2.bmp');
  NextButton.Bitmap.LoadFromFile(F);
end;


procedure BitmapImage1MouseLeave(Sender: TObject);
begin
  F:= ExpandConstant('{tmp}\btnIn1.bmp');
  NextButton.Bitmap.LoadFromFile(F);
end;


//浏览按键 btn_by2
procedure btn_bydown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X: Integer; Y: Integer);
begin
  F:= ExpandConstant('{tmp}\btn_by3.bmp');
  dirCooseImage.Bitmap.LoadFromFile(F);
end;
procedure btn_byup(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X: Integer; Y: Integer);
begin
  F:= ExpandConstant('{tmp}\btn_by2.bmp');
  dirCooseImage.Bitmap.LoadFromFile(F);
end;
procedure btn_bys(Sender: TObject);
begin
  F:= ExpandConstant('{tmp}\btn_by2.bmp');
  dirCooseImage.Bitmap.LoadFromFile(F);
end;


procedure btn_byMouseLeave(Sender: TObject);
begin
  F:= ExpandConstant('{tmp}\btn_by1.bmp');
  dirCooseImage.Bitmap.LoadFromFile(F);
end;


//自定义安装按钮 zdyianZhuangImage
procedure btn_ndown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X: Integer; Y: Integer);
begin
  F:= ExpandConstant('{tmp}\btn_n3.bmp');
  zdyianZhuangImage.Bitmap.LoadFromFile(F);
end;
procedure btn_nup(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X: Integer; Y: Integer);
begin
  F:= ExpandConstant('{tmp}\btn_n2.bmp');
  zdyianZhuangImage.Bitmap.LoadFromFile(F);
end;
procedure btn_nys(Sender: TObject);
begin
  F:= ExpandConstant('{tmp}\btn_n2.bmp');
  zdyianZhuangImage.Bitmap.LoadFromFile(F);
end;


procedure btn_nMouseLeave(Sender: TObject);
begin
  F:= ExpandConstant('{tmp}\btn_n1.bmp');
  zdyianZhuangImage.Bitmap.LoadFromFile(F);
end;


//快速安装
procedure btns_ndown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X: Integer; Y: Integer);
begin
  F:= ExpandConstant('{tmp}\btn_ss3.bmp');
  ksuanZhuangImage.Bitmap.LoadFromFile(F);
end;
procedure btns_nup(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X: Integer; Y: Integer);
begin
  F:= ExpandConstant('{tmp}\btn_ss2.bmp');
  ksuanZhuangImage.Bitmap.LoadFromFile(F);
end;
procedure btns_nys(Sender: TObject);
begin
  F:= ExpandConstant('{tmp}\btn_ss2.bmp');
  ksuanZhuangImage.Bitmap.LoadFromFile(F);
end;


procedure btns_nMouseLeave(Sender: TObject);
begin
  F:= ExpandConstant('{tmp}\btn_ss1.bmp');
  ksuanZhuangImage.Bitmap.LoadFromFile(F);
end;


//返回
procedure backBtn_ndown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X: Integer; Y: Integer);
begin
  F:= ExpandConstant('{tmp}\backBtn3.bmp');
  backBtn.Bitmap.LoadFromFile(F);
end;
procedure backBtn_nup(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X: Integer; Y: Integer);
begin
  F:= ExpandConstant('{tmp}\backBtn2.bmp');
  backBtn.Bitmap.LoadFromFile(F);
end;
procedure backBtn_nys(Sender: TObject);
begin
  F:= ExpandConstant('{tmp}\backBtn2.bmp');
  backBtn.Bitmap.LoadFromFile(F);
end;


procedure backBtn_nMouseLeave(Sender: TObject);
begin
  F:= ExpandConstant('{tmp}\backBtn1.bmp');
  backBtn.Bitmap.LoadFromFile(F);
end;








function ShouldSkipPage(PageID: Integer): Boolean;
begin
if PageID=wpWelcome then
  result := true;
if PageID=wpFinished then
  result := true;
end;


procedure InitializeWizard();
begin
//WizardForm.Width:=482;
//WizardForm.Height:=302;
WizardForm.Width:=587;
WizardForm.Height:=437;
WizardForm.BorderStyle:=bsNone; //去边框
ExtractTemporaryFile('window.bmp');
ExtractTemporaryFile('window2.bmp');
ExtractTemporaryFile('Close1.bmp');
ExtractTemporaryFile('Close2.bmp');
ExtractTemporaryFile('Close3.bmp');
ExtractTemporaryFile('btnIn1.bmp');
ExtractTemporaryFile('btnIn2.bmp');
ExtractTemporaryFile('btnIn3.bmp');
ExtractTemporaryFile('installer.ico');
//按键
ExtractTemporaryFile('DirImg.bmp');
ExtractTemporaryFile('btn_by1.bmp');
ExtractTemporaryFile('btn_by2.bmp');
ExtractTemporaryFile('btn_by3.bmp');
ExtractTemporaryFile('btn_n1.bmp');
ExtractTemporaryFile('btn_n2.bmp');
ExtractTemporaryFile('btn_n3.bmp');
ExtractTemporaryFile('btn_ss1.bmp');
ExtractTemporaryFile('btn_ss2.bmp');
ExtractTemporaryFile('btn_ss3.bmp');
ExtractTemporaryFile('backBtn1.bmp');
ExtractTemporaryFile('backBtn2.bmp');
ExtractTemporaryFile('backBtn3.bmp');




WizardFormImage := TBitmapImage.Create(WizardForm);
WizardFormImage.Parent := WizardForm;
WizardFormImage.Align := alClient;  //图片拉伸
//WizardFormImage.SendToBack;  //显示底部横线
WizardFormImage.Bitmap.LoadFromFile(ExpandConstant('{tmp}\window.bmp'))
WizardFormImage.OnMouseDown:=@WizardFormMouseDown; 
//透明
//SetWindowLong(WizardForm.Handle, GWL_EXSTYLE, GetWindowLong(WizardForm.Handle, GWL_EXSTYLE) or WS_EX_LAYERED)
//SetLayeredWindowAttributes(WizardForm.Handle, TransparentColor,(255 * TransparentPercent) / 100, LWA_COLORKEY)


//系统托盘
  Ico := LoadImage(0, ExpandConstant('{tmp}\face.ico'), IMAGE_ICON, 16, 16, LR_LOADFROMFILE);
  InitTrayIconCtrl(MainForm.Handle, WizardForm.Handle,
             WM_ICON_NOTIFY,   // 自定义自己的消息 ID, 以区分其他消息
             CustomMessage('Tooltip'),  // Tooltip 鼠标在 TrayIcon 图标上移动的时候显示的提示
             Ico,              // 这里默认使用安装程序图标
             True,             // 立即显示, 不用调用 ShowTrayIcon
             False,            // 不显示安装程序的任务栏按钮
             CustomMessage('MenuStrs'),               // 不建立托盘图标菜单
             0,               // 没有默认菜单项
             @TrayMenuItemOnClick,              // 没有菜单点击事件
             @TrayMenuOnPopup,              // 没有菜单弹出事件
             nil               // 没有自定义托盘图标事件
             );


  // 显示漫画型气泡提示
  ShowBalloon(CustomMessage('TooltipText'), CustomMessage('Tooltip'), NIIF_INFO, 10, False);






//关闭按钮
CloseBtn := TBitmapImage.Create(WizardForm);
CloseBtn.ShowHint := True;
CloseBtn.Cursor := crHand;
CloseBtn.OnMouseDown := @CloseBtnOnMouseDown;
CloseBtn.OnMouseUp := @CloseBtnOnMouseUp;
CloseBtn.OnMouseEnter := @CloseBtnOnMouseEnter;
CloseBtn.OnMouseLeave := @CloseBtnOnMouseLeave;
CloseBtn.Parent := WizardForm;
CloseBtn.Width := 22
CloseBtn.Height := 22
CloseBtn.Left := 454+108;
CloseBtn.Top := 3;
CloseBtn.Bitmap.LoadFromFile(ExpandConstant('{tmp}\Close1.bmp'));
CloseBtn.OnClick:= @CloseBtnOnClick;




//自定义安装按钮
zdyianZhuangImage := TBitmapImage.Create(WizardForm);
zdyianZhuangImage.ShowHint := True;
zdyianZhuangImage.Cursor := crHand;
zdyianZhuangImage.Parent := WizardForm;
zdyianZhuangImage.Width := 91;
zdyianZhuangImage.Height := 14;
zdyianZhuangImage.Left := WizardForm.Width - 91 - 20;
zdyianZhuangImage.Top := WizardForm.Height - 30;
zdyianZhuangImage.Bitmap.LoadFromFile(ExpandConstant('{tmp}\btn_n1.bmp'));
zdyianZhuangImage.OnClick:=@setting;
zdyianZhuangImage.OnMouseDown := @btn_ndown;
zdyianZhuangImage.OnMouseUp:=@btn_nup;
zdyianZhuangImage.OnMouseEnter := @btn_nys;
zdyianZhuangImage.OnMouseLeave := @btn_nMouseLeave;


//快速安装ksuanZhuangImage
ksuanZhuangImage := TBitmapImage.Create(WizardForm);
ksuanZhuangImage.ShowHint := True;
ksuanZhuangImage.Cursor := crHand;
ksuanZhuangImage.Parent := WizardForm;
ksuanZhuangImage.Width := 210;
ksuanZhuangImage.Height := 59;
ksuanZhuangImage.Left := (WizardForm.Width - 210)/2;
ksuanZhuangImage.Top := WizardForm.Height/3*2+20;
ksuanZhuangImage.Bitmap.LoadFromFile(ExpandConstant('{tmp}\btn_ss1.bmp'));
ksuanZhuangImage.OnClick:=@en;
ksuanZhuangImage.OnMouseDown := @btns_ndown;
ksuanZhuangImage.OnMouseUp:=@btns_nup;
ksuanZhuangImage.OnMouseEnter := @btns_nys;
ksuanZhuangImage.OnMouseLeave := @btns_nMouseLeave;








//安装按钮
NextButton := TBitmapImage.Create(WizardForm);
NextButton.ShowHint := True;
NextButton.Cursor := crHand;
//NextButton.Parent := WizardForm;
NextButton.Width := 95;
NextButton.Height := 30;
NextButton.Left := WizardForm.Width - 91 - 100;
NextButton.Top := WizardForm.Height -(16 + 30);
NextButton.Bitmap.LoadFromFile(ExpandConstant('{tmp}\btnIn1.bmp'));
NextButton.OnClick:= @en;
NextButton.OnMouseDown := @fdown;
NextButton.OnMouseUp:=@fup;
NextButton.OnMouseEnter := @fs;
NextButton.OnMouseLeave := @BitmapImage1MouseLeave;


//返回按钮
backBtn := TBitmapImage.Create(WizardForm);
backBtn.ShowHint := True;
backBtn.Cursor := crHand;
//backBtn.Parent := WizardForm;
backBtn.Width := 64;
backBtn.Height := 29;
backBtn.Left := NextButton.Left + 95 +10 ;
backBtn.Top := NextButton.Top;
backBtn.Bitmap.LoadFromFile(ExpandConstant('{tmp}\backBtn1.bmp'));
backBtn.OnClick:= @settingbcbtn;
backBtn.OnMouseDown := @backBtn_ndown;
backBtn.OnMouseUp:=@backBtn_nup;
backBtn.OnMouseEnter := @backBtn_nys;
backBtn.OnMouseLeave := @backBtn_nMouseLeave;






                                                                                              
//setbtn := TLabel.Create(WizardForm);
//setbtn.Parent := WizardForm;
//setbtn.Font.Name := '微软雅黑';
//setbtn.Font.Size := 9
//setbtn.Font.Color := $0075FFDD;
//setbtn.Font.Style := [fsUnderline];
//setbtn.Transparent := True;
//setbtn.Cursor:= MyCursor2;
//setbtn.AutoSize := True;
//setbtn.WordWrap := True;
//setbtn.OnClick :=@setting;
//setbtn.Caption := ExpandConstant('高级选项');
//setbtn.SetBounds(ScaleX(20), ScaleY(WizardForm.Top + 120), 50, ScaleY(16));


//setbcbtn := TLabel.Create(WizardForm);
//setbcbtn.Parent := WizardForm;
//setbcbtn.Font.Name := '微软雅黑';
//setbcbtn.Font.Size := 9
//setbcbtn.Font.Color := $0075FFDD;
//setbcbtn.Font.Style := [fsUnderline];
//setbcbtn.Transparent := True;
//setbcbtn.Cursor:= MyCursor2;
//setbcbtn.AutoSize := True;
//setbcbtn.WordWrap := True;
//setbcbtn.OnClick :=@settingbcbtn;
//setbcbtn.Caption := ExpandConstant('返回安装');
//setbcbtn.SetBounds(setbtn.left, setbtn.top, 50, ScaleY(16));


//WizardForm
WizardForm.OuterNotebook.Hide;
WizardForm.BeveledLabel.Width := 0
WizardForm.BeveledLabel.Height := 0
//CancelButton
WizardForm.CancelButton.Width:= 0
WizardForm.CancelButton.Height:= 0
//BackButton
WizardForm.BackButton.Width:= 0
WizardForm.BackButton.Height:= 0
//NextButton
WizardForm.NextButton.Width:= 0
WizardForm.NextButton.Height:= 0


//大标签
bigLabel := TLabel.Create(WizardForm);
bigLabel.Parent := WizardForm;
//bigLabel.Font.Name := '微软雅黑';
bigLabel.Font.Name := 'Microsoft YaHei';
bigLabel.Font.Size := 20
bigLabel.Font.Style := [fsBold];
bigLabel.Font.Color := clWhite;
bigLabel.Transparent := True;
bigLabel.AutoSize := True;
bigLabel.SetBounds(ScaleX(10), ScaleY(25), ScaleY(300), ScaleY(30));
bigLabel.Caption := '{#MyAppName} 安装包'
bigLabel.Show;


//安装版本
sversion := TLabel.Create(WizardForm);
sversion.Parent := WizardForm;
//sversion.Font.Name := '微软雅黑';
sversion.Font.Name := 'Microsoft YaHei';


sversion.Font.Size := 9
sversion.Font.Style := [fsBold];
sversion.Font.Color := clWhite;
sversion.Transparent := True;
sversion.AutoSize := False;
sversion.SetBounds(ScaleX(10), ScaleY(75), ScaleY(300), ScaleY(16));
//sversion.Caption := '安装版本:0001.0000.0001.0002'
sversion.Caption := '{#SversionCaption}';


//添加桌面快捷方式复选框
TaskBox1 := TCheckBox.Create(WizardForm);
TaskBox1.Parent := WizardForm;
TaskBox1.Left := (WizardForm.Width - 446 - 98)/2;
//TaskBox1.Top := ScaleY(413);
TaskBox1.Top := WizardForm.Height -(16 + 40)
TaskBox1.Width := ScaleY(13);
TaskBox1.Height := ScaleY(13);
TaskBox1.Checked := True;
TaskBox1Label := TLabel.Create(WizardForm);
TaskBox1Label.Parent := WizardForm; //位置
TaskBox1Label.Caption := '创建桌面快捷方式';  //控件文字  '#13'
TaskBox1Label.WordWrap := True;
TaskBox1Label.Font.Name := '宋体';
TaskBox1Label.Font.Size := 9  //字体大小
TaskBox1Label.Font.Color := $00000000; //控件文字颜色
TaskBox1Label.Font.Style := []
TaskBox1Label.Transparent := True; //控件透明显示
TaskBox1Label.Left := TaskBox1.Left + TaskBox1.Width + 3//ScaleX(0);
TaskBox1Label.Top := TaskBox1.Top + 1;
TaskBox1Label.Width := 100
TaskBox1Label.Height := TaskBox1.Height;
TaskBox1Label.OnClick := @TaskBox1LabelOnClick;


//--------------------------------------
//目录浏览框
dirviewImage := TBitmapImage.Create(WizardForm);
dirviewImage.ShowHint := True;
dirviewImage.Cursor := crHand;
dirviewImage.Parent := WizardForm;
dirviewImage.Width := 446
dirviewImage.Height := 36
dirviewImage.Left := TaskBox1.Left;
//dirviewImage.Top := WizardForm.Top -20;
dirviewImage.Top := WizardForm.Height -(16 + 130)
dirviewImage.Bitmap.LoadFromFile(ExpandConstant('{tmp}\DirImg.bmp'));


//浏览按钮
dirCooseImage := TBitmapImage.Create(WizardForm);
dirCooseImage.ShowHint := True;
dirCooseImage.Cursor := crHand;
dirCooseImage.Parent := WizardForm;
dirCooseImage.Width := 94;
dirCooseImage.Height := 36;
dirCooseImage.Left := dirviewImage.Left + 446;
dirCooseImage.Top := dirviewImage.Top;
dirCooseImage.Bitmap.LoadFromFile(ExpandConstant('{tmp}\btn_by1.bmp'));
dirCooseImage.OnClick:= @NewDirBrowseButtonClick;
dirCooseImage.OnMouseDown := @btn_bydown;
dirCooseImage.OnMouseUp:=@btn_byup;
dirCooseImage.OnMouseEnter := @btn_bys;
dirCooseImage.OnMouseLeave := @btn_byMouseLeave;




//安装目录
NewLabel := TLabel.Create(WizardForm);
NewLabel.Parent := WizardForm;
NewLabel.Font.Name := '宋体';
NewLabel.Font.Size := 9
NewLabel.Font.Color := $00000000;
NewLabel.Font.Style := []
NewLabel.Transparent := True;
NewLabel.AutoSize := False;
NewLabel.WordWrap := True;
NewLabel.Left := dirviewImage.Left
NewLabel.Top := WizardForm.Height -(16 + 150)
NewLabel.Width := WizardForm.Width - ScaleX(40);
NewLabel.Height := ScaleY(14);




//文字路径
NewDirEdit:=TLabel.Create(WizardForm);
NewDirEdit.Parent:=WizardForm;
NewDirEdit.Transparent:=True;
NewDirEdit.Left:=30;
NewDirEdit.Top:=dirviewImage.top+9;
NewDirEdit.Font.Style := [fsBold];
//NewDirEdit.Font.Color := $0075FFDD;
NewDirEdit.Font.Color := $00000000;
//NewDirEdit.WordWrap := true;
NewDirEdit.Width:= 446;
//NewDirEdit.Cursor:= MyCursor2;
//NewDirEdit.OnClick := @NewDirBrowseButtonClick;
NewDirEdit.hide;








//添加开始菜单程序组快捷方式
TaskBox3 := TCheckBox.Create(WizardForm);
TaskBox3.Parent := WizardForm;
TaskBox3.Left := TaskBox1.Left;
TaskBox3.Top := TaskBox1.Top + 24;
TaskBox3.Width := TaskBox1.Width
TaskBox3.Height := TaskBox1.Height
TaskBox3.Checked := True;
TaskBox3Label := TLabel.Create(WizardForm);
TaskBox3Label.Parent := WizardForm; //位置
TaskBox3Label.Caption := '创建开始菜单程序组快捷方式';
TaskBox3Label.WordWrap := True;
TaskBox3Label.Font.Name := '宋体';
TaskBox3Label.Font.Size := 9  //字体大小
TaskBox3Label.Font.Color := $00000000; //控件文字颜色
TaskBox3Label.Font.Style := []
TaskBox3Label.Transparent := True; //控件透明显示
TaskBox3Label.Left := TaskBox3.Left + TaskBox3.Width + 3//ScaleX(0);
TaskBox3Label.Top := TaskBox3.Top + 1;
TaskBox3Label.Width := 100;
TaskBox3Label.Height := TaskBox3.Height;
TaskBox3Label.OnClick := @TaskBox3LabelOnClick;
//NewStatusLabel
NewStatusLabel := TLabel.Create(WizardForm);
NewStatusLabel.Parent := WizardForm;  //位置
NewStatusLabel.Font.Size := 9  //字体大小
NewStatusLabel.Font.Color := clWhite; //控件文字颜色
NewStatusLabel.Font.Style := []//[fsBold, fsItalic, fsUnderline];  //控件风格:粗体、斜体、下划线
NewStatusLabel.Transparent := True; //控件透明显示
NewStatusLabel.Left := 20
NewStatusLabel.Top := 275;
NewStatusLabel.Width := NewLabel.Width;
NewStatusLabel.Height := ScaleY(14);
//安装百分比
ProgressLabel := TLabel.Create(WizardForm);
ProgressLabel.Top := 255;
ProgressLabel.Left:= 20;
ProgressLabel.Font.Color :=clWhite;
ProgressLabel.AutoSize := True;
ProgressLabel.Transparent := True;
ProgressLabel.Parent := WizardForm;
//ProgressGauge
WizardForm.ProgressGauge.Left:=NewLabel.Left;
WizardForm.ProgressGauge.Top:=NewStatusLabel.Top + NewStatusLabel.Height + 5;
WizardForm.ProgressGauge.Width:=NewLabel.Width;
WizardForm.ProgressGauge.Height:=21
WizardForm.ProgressGauge.Min:=0
WizardForm.ProgressGauge.Max:=100
WizardForm.ProgressGauge.Parent := WizardForm;
//安装细节
//DetaList
DetaList := TNewListBox.Create(WizardForm);
DetaList.Parent := WizardForm;
DetaList.Left := 275;
DetaList.Top := 20;
DetaList.Width := NewLabel.Width;
DetaList.Height := ScaleY(188);
DetaList.TabOrder := ScaleY(4);
DetaList.Visible := False;  //  True默认不显示
DetaList.Color := $00FAF7F2 //细节框颜色
//ShowDetaBtn
ShowDetaBtn := TNewButton.Create(WizardForm);
ShowDetaBtn.Parent := WizardForm;
ShowDetaBtn.Left := DetaList.Left
ShowDetaBtn.Top := DetaList.Top;
ShowDetaBtn.Width := ScaleX(75);
ShowDetaBtn.Height := ScaleY(22);
ShowDetaBtn.Caption := '显示细节(&D)';
ShowDetaBtn.TabOrder := ScaleY(3);
ShowDetaBtn.Visible := True;  // False默认显示
ShowDetaBtn.OnClick := @ShowDetaBtnOnClick;
//FinishedLabel3
FinishedLabel3 := TLabel.Create(WizardForm);
FinishedLabel3.Parent := WizardForm;  //位置
FinishedLabel3.Caption := ExpandConstant('{cm:FinishedHeadingLabel}');  //控件文字  '#13'
FinishedLabel3.WordWrap := True;
FinishedLabel3.Font.Name := '宋体';
FinishedLabel3.Font.Size := 9  //字体大小
FinishedLabel3.Font.Color := clWhite; //控件文字颜色
FinishedLabel3.Font.Style := []//[fsBold, fsItalic, fsUnderline];  //控件风格:粗体、斜体、下划线
FinishedLabel3.Transparent := True; //控件透明显示
FinishedLabel3.Left := ScaleX(60);
FinishedLabel3.Top := ScaleY(100);
FinishedLabel3.Width := ScaleY(435);
FinishedLabel3.Font.Style := [fsBold];
FinishedLabel3.OnMouseDown:=@WizardFormMouseDown;
//程序1
RunBox1 := TCheckBox.Create(WizardForm);
RunBox1.Parent := WizardForm;
RunBox1.Left := FinishedLabel3.Left;
RunBox1.Top := FinishedLabel3.Top + FinishedLabel3.Height + ScaleY(30);
RunBox1.Width := ScaleY(13);
RunBox1.Height := ScaleY(13);
RunBox1.Checked := false//True;
RunBox1Label := TLabel.Create(WizardForm);
RunBox1Label.Parent := WizardForm; //位置
RunBox1Label.Caption := '立即启动酷狗7';  //控件文字  '#13'
RunBox1Label.WordWrap := True;
RunBox1Label.Font.Name := '宋体';
RunBox1Label.Font.Size := 9  //字体大小
RunBox1Label.Font.Color := clWhite; //控件文字颜色
RunBox1Label.Font.Style := []//[fsBold, fsItalic, fsUnderline];  //控件风格:粗体、斜体、下划线
RunBox1Label.Transparent := True; //控件透明显示
RunBox1Label.Left := RunBox1.Left + RunBox1.Width + 3//ScaleX(0);
RunBox1Label.Top := RunBox1.Top + 1;
RunBox1Label.Width := FinishedLabel3.Width - RunBox1.Width - 3;
RunBox1Label.Height := ScaleY(50);
RunBox1Label.OnClick := @RunBox1LabelOnClick;


dirviewImage.Hide;
NewLabel.hide;
NextButton.Hide;
dirCooseImage.Hide;
NewLabel.Hide;
end;


//安装细节
procedure AddToDetaList;
begin
NewStatusLabel.Caption := '抽取:  ' + ExtractFileName(CurrentFileName)  //仅显示文件名称
DetaList.Items.Append('抽取:  ' + ExtractFileName(CurrentFileName));
//滚动
DetaList.ItemIndex := DetaList.Items.Count - 1;
end;


function StatusMsg(MyMsg: string): Boolean;
begin
Result:= True;
NewStatusLabel.Caption:= MyMsg;
end;


procedure Progress();
begin
//安装百分比
ProgressLabel.Caption:= IntToStr((WizardForm.ProgressGauge.Position-WizardForm.ProgressGauge.Min)/((WizardForm.ProgressGauge.Max - WizardForm.ProgressGauge.Min)/101)) + '%';
if((WizardForm.ProgressGauge.Position-WizardForm.ProgressGauge.Min)/((WizardForm.ProgressGauge.Max - WizardForm.ProgressGauge.Min)/101)>=100) then
    begin
    ProgressLabel.Caption:= IntToStr(99) + '%';
    end;
end;


procedure CurPageChanged(CurPageID: Integer);
begin
//    Notice.hide


    NewLabel.hide
    TaskBox1.hide
    TaskBox1Label.hide
//    TaskBox2.hide
//    TaskBox2Label.hide
    TaskBox3.hide
    TaskBox3Label.hide
    NewStatusLabel.hide
    ProgressLabel.hide
    WizardForm.ProgressGauge.hide
    DetaList.hide
    ShowDetaBtn.hide
    FinishedLabel3.hide
    RunBox1.hide
    RunBox1Label.hide
    NextButton.hide
    //setbcbtn.hide
    NewDirEdit.hide
    bigLabel.hide
    sversion.hide
    //setbtn.hide
  if CurPageID = wpWelcome then
    begin
    WizardFormImage.Bitmap.LoadFromFile(ExpandConstant('{tmp}\window.bmp'))
//    Notice.show
    end;
  if CurPageID = wpSelectDir then
    begin
    WizardFormImage.Bitmap.LoadFromFile(ExpandConstant('{tmp}\window.bmp'))
    NextButton.show
    NewLabel.show
    NewLabel.Font.Style := [fsBold];
    TaskBox1.hide
    TaskBox1Label.hide
   //TaskBox2.hide
   // TaskBox2Label.hide
    TaskBox3.hide
    TaskBox3Label.hide
    NewDirEdit.show
    bigLabel.show
    sversion.show
    //setbtn.show
    end;
  if CurPageID = wpInstalling then
    begin
    WizardFormImage.Bitmap.LoadFromFile(ExpandConstant('{tmp}\window.bmp'))
    NewStatusLabel.show
    ProgressLabel.show
    WizardForm.ProgressGauge.hide
    ShowDetaBtn.hide
    bigLabel.show
    sversion.show
    //---------------
    //目录浏览框
    dirviewImage.Hide;
    //选择目录
    dirCooseImage.Hide;
    //自定义安装
    zdyianZhuangImage.Hide;
    //快速安装
    ksuanZhuangImage.Hide;
    //返回
    backBtn.Hide;
    end;
    if CurPageID = wpFinished then
    begin
    WizardFormImage.Bitmap.LoadFromFile(ExpandConstant('{tmp}\window.bmp'))
    FinishedLabel3.show
    RunBox1.show
    RunBox1Label.show
    end;
end;


//快捷方式
Function desktopicon(): Boolean;
begin
  if TaskBox1.Checked = True then     //当TaskBox1选中时,执行操作
  Result := TaskBox1.Checked;
  
end;


Function quicklaunchicon(): Boolean;
begin
  if TaskBox2.Checked = True then     //当TaskBox2选中时,执行操作
  Result := TaskBox2.Checked;
end;


Function groupicon(): Boolean;
begin
  if TaskBox3.Checked = True then     //当TaskBox3选中时,执行操作
  Result := TaskBox3.Checked;
end;


procedure DeinitializeSetup();
begin
MainForm.Hide;
WizardForm.Hide;
UninitTrayIconCtrl();
end;


//安装结束,点"完成"之后运行程序
//procedure CurStepChanged(CurStep: TSetupStep);
//var
//RCode: Integer;
//begin
////程序1
//if (CurStep=ssDone) and (RunBox1.Checked) then
//Exec(ExpandConstant('{app}\MyProg.exe'), '', '', SW_SHOW, ewNoWait, RCode);
////程序2
////if (CurStep=ssDone) and (RunBox2.Checked) then
////Exec(ExpandConstant('{app}\MyProg.exe'), '', '', SW_SHOW, ewNoWait, RCode);
//end;



一些需要注意的地方:

1、inno setup 的版本是否支持字体不同分辨率的适配。

2、在非中文系统上是否会造成乱码。

3、360是否会报毒或者高风险。

4、覆盖安装的时候是否提示。

5、是否允许同时允许多个安装包。

6、安装时如果程序正在运行要进行提示。

一个相对完整的inno setup

标签:

原文地址:http://blog.csdn.net/qq_27175513/article/details/51728747

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!