2016-11-07 115 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