代码之家  ›  专栏  ›  技术社区  ›  Jeremy

显示任务栏上显示的风格

  •  1
  • Jeremy  · 技术社区  · 15 年前

    是否有方法调用MessageBox。显示任务栏中显示的消息?

    当然,最好是创建一个自定义窗体并显示它,但是作为一个懒惰的程序员,我希望避免用一个老式的消息框来重做默认的错误和警报通知图标。显示调用。

    3 回复  |  直到 7 年前
        1
  •  3
  •   Caleb Bell    7 年前

    尝试使用 MessageBoxOptions 枚举:

    MessageBox.Show("Test", "Test", MessageBoxButtons.OK, MessageBoxIcon.Information,
        MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly);
    

    注: 使用这种方法有一些多线程的副作用,请参阅本文 How To Display A User Interface From A Daemon .

        2
  •  1
  •   Tom Anderson    15 年前

    实现一个Iwin32Window,将句柄返回为intptr.zero(桌面),然后以该窗口作为父窗口显示消息框。

        3
  •  1
  •   Dog Ears    15 年前
    private static Image GetImage(MessageBoxIcon icon)
    {
        switch (icon)
        {
            case MessageBoxIcon.Error:
                return System.Drawing.SystemIcons.Error.ToBitmap();
            case MessageBoxIcon.Exclamation:
                return System.Drawing.SystemIcons.Exclamation.ToBitmap();
            case MessageBoxIcon.Information:
                return System.Drawing.SystemIcons.Information.ToBitmap();
            case MessageBoxIcon.Question:
                return System.Drawing.SystemIcons.Question.ToBitmap();
        }
        return null;
    }