2011-06-14 46 views
2

我需要在運行時更改消息。我有一個AfterInstall過程,檢查bat文件是否成功。如果不是,我想在調用WizardForm.Close之前更改ExitSetupMessage的值。我希望能做這樣的事情。english.ExitSetupMessage:='這是不工作的部分';代碼示例將不勝感激。謝謝。Inno Setup:如何在運行時更改消息?

[Languages] 
Name: english; MessagesFile: compiler:Default.isl 

[Files] 
Source: {src}\test.bat; DestDir: {tmp}; AfterInstall: ValidateInstall 

[Code] 
procedure ValidateInstall(); 
var 
    ResultCode : Integer; 
begin 
    if not Exec(ExpandConstant('{tmp}\test.bat'), '', '', SW_HIDE, ewWaitUntilTerminated, ResultCode) then 
    begin 
     english.ExitSetupMessage := 'THIS IS THE PART THAT DOES NOT WORK'; 
     WizardForm.Close; 
    end; 
end; 

回答

1

我不知道在運行時更改消息的方法。

但是,在您發佈的情況下,我知道一個解決方法。你會調用WizardForm.Close

var 
    CustomState : Boolean; 

procedure CancelButtonClick(CurPageID: Integer; var Cancel, Confirm: Boolean); 
var 
Msg : String; 
Res : Integer; 
begin 
Confirm := False; // Don't show the default dialog. 

// Chose which message the custom or default message. 
if CustomState then 
    Msg := 'My Custom Close Message' 
else 
    Msg := SetupMessage(msgExitSetupMessage); 

//as the Question 
Res := MsgBox(Msg, mbConfirmation,MB_OKCANCEL); 

// If they press OK then Cancel the install 
Cancel := (Res = IDOK); 

end; 

副作用之前設置你的CustomState是你失去了Exit Setup?標題對話框。

如果您不想更改消息 以保留標題,則可以使用function ExitSetupMsgBox: Boolean;

+0

這正是我所期待的。謝謝。 – PM2 2011-06-15 20:44:00

相關問題