如何删除/隐藏/禁用消息框上的[确定]按钮 [英] How to Delete / Hide / Disable [OK] button on message box

查看:84
本文介绍了如何删除/隐藏/禁用消息框上的[确定]按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是代码...

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;

我只希望出现没有按钮的消息框.要添加或删除什么代码?我要在哪里插入?谢谢!

I just want the message box to appear without the button. What code to be added or removed? Where would I insert it? Thanks!

这是否来自如何在Inno Setup中禁用向导表单上的下一步"按钮?我的剧本?我似乎无法使其正常工作.

Does this a code from How to disable the "Next" button on the wizard form in Inno Setup? work with my script? I can't seem to to make it working.

推荐答案

您不能.

但是,正如您已经从 MsgBox知道的那样-设置不可点击的OK按钮并更改为倒数计时-Inno Setup ,您可以实施消息框从头开始.这样,您可以按自己的方式自定义它.

But as you already know from MsgBox - Make unclickable OK Button and change to countdown - Inno Setup, you can implement the message box from a scratch yourself. This way, you can customize it any way you want.

实际上,您所需要做的就是从我对上述问题的回答中删除按钮.

Actually, all you need is to remove the button from my answer to the above question.

[Code]

function SetTimer(hWnd: LongWord; nIDEvent, uElapse: LongWord; 
  lpTimerFunc: LongWord): LongWord; external 'SetTimer@user32.dll stdcall';
function KillTimer(hWnd: HWND; uIDEvent: LongWord): BOOL;
  external 'KillTimer@user32.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;
  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;

    Timer := SetTimer(0, 0, 1000, CreateCallback(@TimeoutProc));

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

对于 CreateCallback函数,您需要Inno设置6.如果您对Inno Setup 5感到困惑,可以使用 InnoTools中的WrapCallback函数InnoCallback 库.

For CreateCallback function, you need Inno Setup 6. If you are stuck with Inno Setup 5, you can use WrapCallback function from InnoTools InnoCallback library.

这篇关于如何删除/隐藏/禁用消息框上的[确定]按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆