MFC 中的就地消息?

发布于 2024-10-17 13:55:35 字数 408 浏览 3 评论 0原文

你好 如果有人知道如何在 MFC 中使用就地警告消息,您可以分享信息吗? 有没有办法使用或者有什么控件我们可以直接在mfc中使用。

就地警告消息:带有相应图标的警告消息和警告消息将显示在同一对话框中。

我在msdn中找到了一些有关就地消息的信息

msdn 术语表中的就地消息< /a>

不同消息

请分享信息。

问候

哈拉纳德

Hi
If any one knows how to use in-place warning message in MFC could you share info.
Is there a way to use it or is there any control we can use directly in mfc.

In-Place warning message: A warning message with appropriate icon along with warning message, will be displayed with in the same dialog.

I found some info about in-place message in msdn

InPlace message in msdn glossary

Different messages

Please share information.

Regards

Haranadh

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

愛放△進行李 2024-10-24 13:55:35

从您的评论来看,您似乎将此视为就地消息:

   

当然,具有讽刺意味的是,在您链接到的 MSDN 页面上,该示例被标记为不正确示例。特别建议您提供更具体的建议,例如使用密码保护投影仪,以便非预期观看者无法看到演示文稿。不过,抛开这一点...

这在 MFC 中实现起来非常容易。只需使用两个 STATIC 控件即可完成,左侧的一个显示图标(在本例中为警告三角形),右侧较长的一个显示静态文本(警告消息本身)。如果您使用对话框编辑器创建窗口,则只需将两个控件拖动到对话框窗口并相应地排列它们即可。没有一个控件可以封装此功能,但考虑到使用两个单独的静态控件已经如此简单,期望会有这样的功能是愚蠢的。

要加载内置图标(例如上面显示的警告三角形),您可以使用 LoadStandardIcon 函数 并指定 IDI_WARNING 作为图标名称。完整的值列表位于此处。显然,您也可以加载您选择的任何图标;只需将其添加到您的项目资源中即可。

由于您可能希望仅在适用时才显示警告消息,因此您需要根据用户在对话框中采取的操作以编程方式隐藏和显示这两个控件。标准的 ShowWindow 成员函数使这成为一项微不足道的任务。如果您希望警告消息可见,请在两个静态控件上调用它,并传递 SW_SHOW 作为其参数。否则,您可以指定 SW_HIDE 来隐藏控件。

From your comment, it appears that you're referring to this as an in-place message:

   

Ironically, of course, that's labeled as the incorrect example on the MSDN page that you link to. It's specifically recommended that you provide more specific advice, such as securing the projector with a password so that the presentation is not visible to unintended viewers. Putting that aside, however...

This is quite easy to implement in MFC. It's done simply with two STATIC controls, one on the left that displays an icon (in this case, a warning triangle) and the longer one on the right that displays static text (the warning message itself). If you're using the dialog editor to create your window, it's a simple matter of dragging the two controls to the dialog window and arranging them accordingly. There isn't a single control that encapsulates this functionality, but it's silly to expect that there would be, considering that doing it with two separate static controls is already so straightforward.

To load built-in icons such as the warning triangle shown above, you can use the LoadStandardIcon function and specify IDI_WARNING as the icon name. The complete list of values is available here. Obviously you can load any icon of your choosing as well; just add it to your project's resources.

Since you will presumably want to display the warning message only when it's applicable, you will need to programmatically hide and show the two controls depending on action taken by the user in your dialog. The standard ShowWindow member function makes this a trivial task. Call it on the two static controls, passing SW_SHOW as its argument if you want the warning message to be visible. Otherwise, you can specify SW_HIDE to hide the control.

寄离 2024-10-24 13:55:35

作为您正在尝试做的事情的替代方案;您可以将消息放入对话框中:

int nResult = AfxMessageBox("Save changes to Current Job?", MB_YESNO);

    if (nResult == IDYES)
    {
        OnFileSave();
    } 

As an alternative to what you are trying to do; you could place your message in a dialog:

int nResult = AfxMessageBox("Save changes to Current Job?", MB_YESNO);

    if (nResult == IDYES)
    {
        OnFileSave();
    } 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文