如何显示指定时间的消息框?

编程入门 行业动态 更新时间:2024-10-28 09:22:48
本文介绍了如何显示指定时间的消息框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

有没有一种方法可以显示指定时间的消息框(这意味着消息框将在指定时间过去后自动关闭)?

Is there a way to show a message box for a specified time (that means, the message box will close itself when the specified time elapses) ?

推荐答案

Windows API具有在指定时间显示消息框的功能,但是由于某些原因该功能未记录,这意味着它未被正式支持,并且可能随时可能会发生变化.

Windows API has a function for showing a message box for a specified time, but for some reason is that function undocumented, which means it is not officially supported and may well be subject to change.

该函数称为MessageBoxTimeout,甚至在user32.dll库中都已导出,这让我感到此函数唯一缺少的是官方文档.但是谁知道...

That function is called MessageBoxTimeout, and it has even export in the user32.dll library, what makes me feel that the only thing this function lacks is the official documentation. But who knows...

以下脚本显示在显示向导表单之前如何显示消息框5秒钟.如果用户没有单击确定"按钮,也没有手动关闭窗口,则在经过5秒钟后,消息框将自动关闭:

The following script shows how to display a message box for 5 seconds before the wizard form is shown. If the user doesn't click the OK button, nor manually close the window, the message box is automatically closed when that 5 seconds period elapses:

[Code] #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, 'This message will be automatically ' + 'closed in 5 seconds!', 'Caption...', MB_OK or MB_ICONINFORMATION, 0, 5000); end;

有关参数和结果值的更多信息,请参考 MessageBox 函数帮助站点以及一些描述MessageBoxTimeout函数本身的非正式文章,例如:

For more information about parameters and result values refer to the MessageBox function help site and some of the unofficial articles describing the MessageBoxTimeout function itself, like e.g.:

  • 毛里齐奥·皮萨诺(Maurizio Pisano):MessageBoxTimeout API(CodeProject)
  • Eddie Shipman:未记录的MessageBoxTimeOut函数(Embarcadero)
  • Maurizio Pisano: MessageBoxTimeout API (CodeProject)
  • Eddie Shipman: Undocumented MessageBoxTimeOut function (Embarcadero)

更多推荐

如何显示指定时间的消息框?

本文发布于:2023-11-24 09:55:24,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1624744.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:消息   时间

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!