如何在运行时更改MsgBox消息标题? [英] How to change MsgBox message caption at runtime?

查看:329
本文介绍了如何在运行时更改MsgBox消息标题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在运行时更改MsgBox消息框的默认标题.当前,它会不断将SetupAppTitle指令的值显示为标题:

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 a caption:

[Setup]
SetupAppTitle=myAppName

但这是在编译时指定的.如何在运行时执行此操作,例如来自[Code]部分?

But this is specified at compilation time. How to do this at runtime, e.g. from a [Code] section ?

推荐答案

这是我最终做到的方式:

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;

感谢大家的帮助!

这篇关于如何在运行时更改MsgBox消息标题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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