2016-11-07 182 views
0

/隱藏/禁用[確定]按鈕下面的代碼...如何刪除消息框

ifdef UNICODE 
    #define AW "W" 
#else 
    #define AW "A" 
#endif 
const 
    MB_TIMEDOUT = 32000; 
    MB_ICONERROR = $10; 
    MB_ICONQUESTION = $20; 
    MB_ICONWARNING = $30; 
    MB_ICONINFORMATION = $40; 

function MessageBoxTimeout(hWnd: HWND; lpText: string; lpCaption: string; 
    uType: UINT; wLanguageId: Word; dwMilliseconds: DWORD): Integer; 
    external 'MessageBoxTimeout{#AW}@user32.dll stdcall'; 

procedure InitializeWizard; 
begin 
    MessageBoxTimeout(WizardForm.Handle, 'Some ' + 
    'message', 'Setup', MB_OK or MB_ICONINFORMATION, 0, 5000); 
end; 

我只是想顯示的消息框沒有按鈕。要添加或刪除哪些代碼?我會在哪裏插入它?謝謝!

這是How to disable the 「Next」 button on the wizard form in Inno Setup?的代碼與我的腳本一起工作嗎?我似乎無法使其工作。

+0

我添加一些代碼來我的答案。 –

回答

1

你不能。

但是正如您從MsgBox - Make unclickable OK Button and change to countdown - Inno Setup知道的那樣,您可以自己從頭開始實現消息框。這樣,你可以任何你想要的方式來定製它。

其實,你所需要的只是從我對上述問題的回答中刪除按鈕。

[Files] 
Source: InnoCallback.dll; Flags: dontcopy 

[Code] 

type 
    TTimerProc = procedure(H: LongWord; Msg: LongWord; IdEvent: LongWord; Time: LongWord); 

function SetTimer(hWnd: LongWord; nIDEvent, uElapse: LongWord; 
    lpTimerFunc: LongWord): LongWord; external '[email protected] stdcall'; 
function KillTimer(hWnd: HWND; uIDEvent: LongWord): BOOL; 
    external '[email protected] stdcall'; 
function WrapTimerProc(Callback: TTimerProc; ParamCount: Integer): LongWord; 
    external '[email protected]:innocallback.dll stdcall'; 

var 
    TimeoutForm: TSetupForm; 

procedure TimeoutProc(H: LongWord; Msg: LongWord; IdEvent: LongWord; Time: LongWord); 
begin 
    TimeoutForm.Tag := TimeoutForm.Tag - 1; 
    if TimeoutForm.Tag = 0 then 
    begin 
    TimeoutForm.Close; 
    end; 
end; 

procedure TimeoutMessageBoxCloseQuery(Sender: TObject; var CanClose: Boolean); 
begin 
    { Prevent the dialog from being closed by the X button and Alt-F4 } 
    CanClose := (TimeoutForm.Tag = 0); 
end; 

procedure TimeoutMessageBox(Message: string; Seconds: Integer); 
var 
    MessageLabel: TLabel; 
    TimeoutCallback: LongWord; 
    Timer: LongWord; 
begin 
    TimeoutForm := CreateCustomForm; 
    try 
    TimeoutForm.ClientWidth := ScaleX(256); 
    TimeoutForm.ClientHeight := ScaleY(64); 
    TimeoutForm.Caption := 'Information'; 
    TimeoutForm.Position := poMainFormCenter; 
    TimeoutForm.OnCloseQuery := @TimeoutMessageBoxCloseQuery; 
    TimeoutForm.Tag := Seconds; 

    MessageLabel := TLabel.Create(TimeoutForm); 
    MessageLabel.Top := ScaleY(16); 
    MessageLabel.Left := ScaleX(16); 
    MessageLabel.AutoSize := True; 
    MessageLabel.Caption := Message; 
    MessageLabel.Parent := TimeoutForm; 

    TimeoutCallback := WrapTimerProc(@TimeoutProc, 4); 
    Timer := SetTimer(0, 0, 1000, TimeoutCallback); 

    try 
     TimeoutForm.ShowModal(); 
    finally 
     KillTimer(0, Timer); 
    end; 
    finally 
    TimeoutForm.Free(); 
    TimeoutForm := nil; 
    end; 
end; 

enter image description here

+0

當我將它粘貼到[代碼]中時,MsgBox不顯示。它指導安裝。我添加了你的代碼[http://stackoverflow.com/questions/40446269/msgbox-make-unclickable-ok-button-and-change-to-countdown-inno-setup#comment68149019_40447154],但它有錯誤[http:// – DDoS

+0

顯然,因爲這裏的關鍵函數被稱爲'TimeoutMessageBox',而不是'CountdownMessageBox'。 –

+0

謝謝! :) 有效! – DDoS