创建像 Windows Messenger 或 AVG 一样的弹出气球

发布于 2024-07-11 10:04:06 字数 156 浏览 5 评论 0原文

如何创建一个弹出气球,就像您在 Windows Messenger、AVG、Norton 或其他任何程序中看到的那样?

我希望它显示信息,然后几秒钟后滑开。

编辑:它需要像 Form.ShowDialog() 一样阻塞,因为程序在显示通知后退出

How can I create a Popup balloon like you would see from Windows Messenger or AVG or Norton or whomever?

I want it to show the information, and then slide away after a few seconds.

Edit: It needs to be blocking like Form.ShowDialog() because the program exits after displaying the notification

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

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

发布评论

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

评论(3

短叹 2024-07-18 10:04:06

您可以使用属于.NET 2.0 System.Windows.Forms 的notifyIcon 控件。 这允许您在系统托盘中放置应用程序的图标。 然后,您可以调用 ShowBalloonTip(int timeOut) 方法。 不过,请务必先设置 notificationIcon 上的文本和图标属性,才能使其正常工作。 小代码示例:

private void button1_Click(object sender, EventArgs e)
        {
            this.notifyIcon1.BalloonTipText = "Whatever";
            this.notifyIcon1.BalloonTipTitle = "Title";
            this.notifyIcon1.Icon = new Icon("icon.ico");
            this.notifyIcon1.Visible = true;
            this.notifyIcon1.ShowBalloonTip(3);
        }

编辑:好的,所以 notificationIcon 不适合你。 我的第二个建议是为此创建您自己的控件。 实际上,我会使用表格。 一个简单的表单,没有边框,没有控制框,只有一个计时器运行,这样您就可以设置淡入/淡出的不透明度。 然后,您可以使用矩形 Screen.PrimaryScreen.WorkingArea 轻松获取屏幕的右下角。 然后只需在该位置展示您的表格即可。

You can use the notifyIcon control that's part of .NET 2.0 System.Windows.Forms. That allows you to place an icon for your application in the System Tray. Then, you can call the ShowBalloonTip(int timeOut) method on that. Be sure however to first set the text, and icon properties on the notifyIcon for it to work. Small code sample:

private void button1_Click(object sender, EventArgs e)
        {
            this.notifyIcon1.BalloonTipText = "Whatever";
            this.notifyIcon1.BalloonTipTitle = "Title";
            this.notifyIcon1.Icon = new Icon("icon.ico");
            this.notifyIcon1.Visible = true;
            this.notifyIcon1.ShowBalloonTip(3);
        }

EDIT: Ok, so notifyIcon won't work for you. My second suggestion would then be to create your own control for this. Actually, I would use a form. A simple form, with no borders, and no control box and just have a timer running so you can set the Opacity for fade in/out. Then, you can easily get the bottom right of the screen using the Rectangle Screen.PrimaryScreen.WorkingArea. Then just show your form at that position.

无人问我粥可暖 2024-07-18 10:04:06

不要创建模态(阻塞)气球。 请。 这些 UI 设计的一个重要部分是它们不是对话框:它们是瞬态的、可能非交互元素,旨在向用户提供附带信息<不一定会中断他们的工作流程。 窃取焦点并阻止用户输入的气球充其量只是令人恼火 - 如果您需要一个对话框,那么就使用对话框。

Don't create a modal (blocking) balloon. Please. A big part of the design of these UIs is that they are not dialogs: they're transient, potentially non-interactive elements, intended to provide incidental information to a user without necessarily interrupting their workflow. A balloon that steals focus and blocks user input would be irritating at best - if you need a dialog, then use a dialog.

勿挽旧人 2024-07-18 10:04:06

.NET 1.1 Visual Basic Power Pack 有一个烤面包机控件。

The .NET 1.1 Visual Basic Power Pack had a toaster control.

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