2015-09-08 54 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