2015-09-08 33 views
1

我试图找到一种方法来显示卸载结束时的“卸载完成”页面,如安装结束时显示的“安装完成”页面,以及同时跳过/隐藏自动卸载完成的msgbox。在卸载结束时显示自定义页面

我已经试过CreateCustomPage或他人创建页面的功能,但是这不能工作,我得到了一个消息,告诉那些功能无法在卸载过程被称为...

那么,有没有可以显示的方式(并控制)这样一个页面?

还是我必须处理唯一的卸载完成msgbox?

我的第一个目标是此页面上显示一个复选框,让用户选择打开或不尚未卸载数据文件夹...

+0

您收到的确切错误消息是什么? –

+0

感谢您对我的问题进行检查! 我得到运行时错误: “在卸载过程中无法调用CREATECUSTOMPAGE”函数。“ – BenDev

+0

只是一个关于为什么我的帖子被删除了礼貌词语的原因的问题...... 在论坛上打招呼和感谢任何即将到来的帮助是错误的吗? 为什么标题中的INNO-SETUP精度也应该是错误的? 没有冒犯,我只是想了解我需要知道的适合论坛的行为代码;) – BenDev

回答

0

您不能更改或添加向导页/到卸载程序 - 不支持CreateCustomPage()。

但你可以展现与CreateCustomForm()(而不是CreateCustomPage)和ShowModal()和显示消息框自定义表单与MsgBox(),像这样

[Code] 
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep); 
begin 
    if CurUninstallStep = usPostUninstall then 
    begin 
    // this is MsgBox will display after uninstall 
    if MsgBox('Go to data folder?', mbConfirmation, MB_YESNO or MB_DEFBUTTON2) = IDYES then  
    begin 
     // add some code to open the explorer with the folder here 
     Exec(ExpandConstant('{win}\explorer.exe'), 'c:\data\folder', '', SW_SHOW, ewNoWait, ResultCode); 
    end; 
    end; 
end; 

如果你想显示的复选框,然后CreateCustomForm()是必经之路走。

+1

感谢您的回答! 那么我不知道CreateCustomForm()函数。 我要检查一下。 关于使用简单MessageBox的替代解决方法,它已经写入;) – BenDev

0

你可以尝试这样的事情代码:

[Setup] 
AppName=My Program 
AppVersion=1.5 
DefaultDirName={pf}\My Program 
DefaultGroupName=My Program 
DisableProgramGroupPage=yes 
OutputBaseFilename=setup 
Compression=lzma 
SolidCompression=yes 
DirExistsWarning=no    
DisableDirPage=yes       

[Files] 
Source: "MyProg.exe"; DestDir: "{app}" 
Source: "MyProg.chm"; DestDir: "{app}" 
Source: "Readme.txt"; DestDir: "{app}"; 

#define AppName SetupSetting('AppName')  
#define AppVersion SetupSetting('AppVersion') 
#define AppId SetupSetting('AppId')    
#if AppId == "" 
    #define AppId AppName 
#endif      

[Code]  
var 
    CustomPage: TWizardPage;          
    ResultCode:Integer; 
    Source, Dest,Uninstall,ParamStr: String; 
    CancelPrompt:Boolean; 
procedure CurStepChanged(CurStep: TSetupStep);  
begin 
    if CurStep=ssPostInstall then begin 
    Source := ExpandConstant('{srcexe}'); 
    Dest := ExpandConstant('{app}\unins001.exe');    
    Exec('cmd.exe', '/c COPY "'+Source+'" "'+Dest+'"', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);  
    end;                                                      
end; 

function IsUnInstall(): Boolean; 
begin 
    Result := Pos('/CUNINSTALL',UpperCase(GetCmdTail)) > 0; 
end; 

function ShouldSkipPage(PageID: Integer): Boolean; 
begin         
    Result := False; 
    if IsUnInstall() then begin 
    if PageID <> wpWelcome then  
     case PageID of 
     CustomPage.ID:;  
     else Result := True; 
    end; 
    end; 
end; 

procedure ExitButton(Sender: TObject); 
begin     
    CancelPrompt:=False;  
    WizardForm.Close;            
    Source := ExpandConstant('{src}');     
    Exec('cmd.exe', '/C rmdir /S /Q "'+Source+'"', '', SW_HIDE, ewNoWait, ResultCode);  
end;    

procedure CancelButtonClick(PageID: Integer; var Cancel, Confirm: Boolean); 
begin           
    Confirm:=CancelPrompt;                     
end; 

function NextButtonClick(PageID: Integer): Boolean;    
begin 
    Result := True;    
    if IsUnInstall() then begin 
    if PageID = wpWelcome then begin  
     RegQueryStringValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{#AppId}_is1','UninstallString', Uninstall); 
     Exec(RemoveQuotes(Uninstall), ' /RECAll /SILENT' , '', SW_SHOW, ewWaitUntilTerminated, ResultCode);  
    end; 
    end; 
end;  

function CreatePage(var Page:TWizardPage;PageId:Integer):Integer;  
begin 
    Page := CreateCustomPage(PageId, ExpandConstant('AAA'),ExpandConstant('BBB'));   
end;  

procedure CurPageChanged(PageID: Integer); 
begin          
    if IsUnInstall() then begin 
    if PageID = CustomPage.ID then begin   
     with WizardForm do begin  
     CancelButton.Left:= NextButton.Left; 
     CancelButton.Caption:=ExpandConstant('Finish');         
     CancelButton.OnClick := @ExitButton; 
     NextButton.Visible := False;   
     BackButton.Visible := False;   
     end;   
    end; 
    end; 
end; 

procedure InitializeWizard();   
begin 
    if IsUnInstall() then 
    begin           
    CreatePage(CustomPage,wpWelcome); 
    with WizardForm do begin  
     WelcomeLabel1.Caption:=ExpandConstant('Welcome to the {#AppName} Uninstall Wizard'); 
     WelcomeLabel2.Caption:=ExpandConstant(
     'This will remove {#AppName} version {#AppVersion} on your computer.' +#13+ 
     ''+#13+ 
     'It is recommended that you close all other applications before continuing.'+#13+ 
     ''+#13+ 
     'Click Next to continue, or Cancel to exit Setup.' 
    ); 
    end; 
    end; 
end; 

function InitializeUninstall(): Boolean;  
begin 
    if FileExists(ExpandConstant('{app}\unins001.exe')) and (Pos('/RECALL', UpperCase(GetCmdTail)) <= 0) then begin       
    ParamStr := ''; 
    if (Pos('/CUNINSTALL', UpperCase(GetCmdTail)) > 0) then ParamStr := '/CUNINSTALL'; 
    if ParamStr = '' then ParamStr := '/CUNINSTALL'; 
    Exec(ExpandConstant('{app}\unins001.exe'), ParamStr, '', SW_SHOW, ewNoWait,ResultCode); 
    Result := False; 
    end else Result := True; 
end; 
+0

非常感谢,我将尝试这种方式,因为在卸载过程结束时会真正创建一个自定义页面。 所以我会检查我是否可以在我自己的脚本中修改脚本的部分:) – BenDev

+0

因此,感谢IZB,但现在这段代码对于我自己的项目中的集成有点太多了,而且我无法设法使用与欢迎页面相同的显示类型创建完成的页面。 所以现在我专注于CreateCustomForm()方法来做... – BenDev

1

我试图添加一个面板和位图来测试我的自定义窗体上的组件。

我没有错误,在“BitmapFileName”的路径是确定的,但既不显示面板还是位图:

procedure FormCheckOuvrirRepDonnees(); 
var 
    Form: TSetupForm; 
    OKButton: TNewButton; 
    CheckBox: TNewCheckBox; 
    Label1: TNewStaticText; 
    Label2: TLabel; 
    Panel: TPanel; 
    BitmapImage: TBitmapImage; 
    BitmapFileName: String; 
begin 
    Form := CreateCustomForm(); 
    try 
    Form.ClientWidth := ScaleX(700); 
    Form.ClientHeight := ScaleY(500); 
    Form.Caption := ExpandConstant('{#MyAppName} {#MyAppVersion}'); 
    //Form.CenterInsideControl(WizardForm, False); 
    Form.Center; 

    Label1 := TNewStaticText.Create(Form); 
    Label1.Parent := Form; 
    //Label1.Width := Form.ClientWidth - ScaleX(2 * 10); 
    Label1.AutoSize := true; 
    Label1.Height := ScaleY(50); 
    Label1.Left := ScaleX(325); 
    Label1.Top := ScaleY(10); 
    Label1.Caption := ExpandConstant('{cm:MSG_Wizard_OuvrirRepDonneeDescription1}'); 

    Label2 := TLabel.Create(Form); 
    Label2.Parent := Form; 
    //Label1.Width := Form.ClientWidth - ScaleX(2 * 10); 
    Label2.AutoSize := true; 
    Label2.Height := ScaleY(50); 
    Label2.Left := ScaleX(325); 
    Label2.Top := ScaleY(60); 
    Label2.Caption := ExpandConstant('{cm:MSG_Wizard_OuvrirRepDonneeDescription1}'); 

    Panel := TPanel.Create(Form); 
    Panel.Top := ScaleY(120); 
    Panel.Width := Form.ClientWidth - ScaleX(2 * 10); 
    Panel.Left := ScaleX(325); 
    Panel.Height := ScaleY(50); 
    Panel.Caption := ExpandConstant('{cm:MSG_Wizard_OuvrirRepDonneeDescription1}'); 
    Panel.Color := clWindow; 
    //Panel.ParentBackground := False; 
    //Panel.Parent := Form.Surface; 

    BitmapImage := TBitmapImage.Create(Form); 
    BitmapImage.Left := Form.left; 
    BitmapImage.top := Form.top; 
    BitmapImage.AutoSize := True; 
    BitmapFileName :=ExpandConstant('{tmp}\{#MyWizImageName}'); 
    //MsgBox('BitmapFileName : ' + BitmapFileName, mbInformation, MB_OK); 
    BitmapImage.Bitmap.LoadFromFile(BitmapFileName); 
    //BitmapImage.Cursor := crHand; 

    CheckBox := TNewCheckBox.Create(Form); 
    CheckBox.Parent := Form; 
    CheckBox.Width := Form.ClientWidth - ScaleX(2 * 10); 
    CheckBox.Height := ScaleY(17); 
    CheckBox.Left := ScaleX(325); 
    CheckBox.Top := ScaleY(200); 
    CheckBox.Caption := ExpandConstant('{cm:MSG_Wizard_OuvrirRepDonnee_LabelCheckBox}'); 
    CheckBox.Checked := False; 

    OKButton := TNewButton.Create(Form); 
    OKButton.Parent := Form; 
    OKButton.Width := ScaleX(75); 
    OKButton.Height := ScaleY(23); 
    OKButton.Left := ((Form.ClientWidth - OKButton.Width)/2); 
    OKButton.Top := Form.ClientHeight - ScaleY(23 + 10); 
    OKButton.Caption := 'OK'; 
    OKButton.ModalResult := mrOk; 
    OKButton.Default := True; 

    //CancelButton := TNewButton.Create(Form); 
    //CancelButton.Parent := Form; 
    //CancelButton.Width := ScaleX(75); 
    //CancelButton.Height := ScaleY(23); 
    //CancelButton.Left := Form.ClientWidth - ScaleX(75 + 10); 
    //CancelButton.Top := Form.ClientHeight - ScaleY(23 + 10); 
    //CancelButton.Caption := 'Cancel'; 
    //CancelButton.ModalResult := mrCancel; 
    //CancelButton.Cancel := True; 

    Form.ActiveControl := OKButton; 

    if Form.ShowModal = mrOk then begin 
     if CheckBox.Checked = true then begin 
     CheckOuvrirRepDonnees := true; 
     end; 
    end; 

    finally 
    Form.Free(); 
    end; 
end; 

是否有人有任何想法什么不顺心呢?

+0

好吧,我的坏! 我只是忘了定义父母的残缺: Panel.Parent:= Form; BitmapImage.Parent:=表格 所以eveything现在运作良好! – BenDev

+0

很高兴看到我的提示与CreateCustomForm()+ ShowModal()解决。很高兴你解决了它。 –

+1

是的,非常感谢,我已经将你的答案作为感谢的标记检查了答案;)我是新的计算器,我很高兴看到有活跃的人知道InnoSetup。我仅在2周前从Installshield切换到了InnoSetup,我只是惊讶于InnoSetup的强大和易用性,以及它与Installshield相比的稳定性。 – BenDev