How to change MsgBox message caption at runtime?

前端 未结 2 1819
独厮守ぢ
独厮守ぢ 2020-12-01 13:41

I need to change the default caption of a MsgBox message box at runtime. Currently it constantly shows the value of the SetupAppTitle directive as

2条回答
  •  無奈伤痛
    2020-12-01 14:14

    This is how i finally did it:

    [Code]
    { https://msdn.microsoft.com/en-us/library/windows/desktop/ms645505.aspx }
    { Use Windows MessageBox() function as an MsgBox() replacement. }
    { MessageBoxW is the UNICODE version of this API call. }
    const
      { these are not exported in Inno Setup! }
      MB_ICONERROR = $00000010;
      MB_ICONWARNING = $00000030;
      MB_ICONINFORMATION = $00000040;
      MB_ICONQUESTION = $00000020;
    
    function _MessageBoxW_(hWnd: Integer; lpText, lpCaption: String; uType: Cardinal): Integer;
      external 'MessageBoxW@user32.dll stdcall';
    
    { Usage: SysMsgBox('Error', 'Shit happens!', MB_OK or MB_ICONERROR); }
    {        res =: SysMsgBox('Question', 'blah blah', MB_YESNO or  MB_ICONQUESTION); }
    function SysMsgBox(const Caption, Message: String; const Flags: Integer): Integer;
    begin
      Result :=
        _MessageBoxW_(StrToInt(ExpandConstant('{wizardhwnd}')), Message, Caption, Flags);
    end;
    

    Thanks to all for your help!

提交回复
热议问题