读书人

C#泡沫提示

发布时间: 2012-08-08 14:32:45 作者: rapoo

C#泡泡提示
就如电脑一插入USB时,右下角的托盘图标就会有个"泡泡提示框",就像看卡通,漫画里的说话框一样的...

那个用C Shape如何做?

我像我的程序打开后,右下角的托盘会有提示...

或是最小化时也有

[解决办法]
这个,应该要用第三方控件吧。
自己写的话感觉有点麻烦
[解决办法]

试试吧!

C# code
namespace WindowsApplication1{    partial class Form1    {        /// <summary>        /// 必需的设计器变量。        /// </summary>        private System.ComponentModel.IContainer components = null;        /// <summary>        /// 清理所有正在使用的资源。        /// </summary>        /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>        protected override void Dispose(bool disposing)        {            this.notifyIcon1.ShowBalloonTip();            //if (disposing && (components != null))            //{            //    components.Dispose();            //}            //base.Dispose(disposing);        }        #region Windows 窗体设计器生成的代码        /// <summary>        /// 设计器支持所需的方法 - 不要        /// 使用代码编辑器修改此方法的内容。        /// </summary>        private void InitializeComponent()        {            this.components = new System.ComponentModel.Container();            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));            this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components);            this.SuspendLayout();            //             // notifyIcon1            //             this.notifyIcon1.BalloonTipIcon = System.Windows.Forms.ToolTipIcon.Info;            this.notifyIcon1.BalloonTipText = "服务已启动";            this.notifyIcon1.BalloonTipTitle = "Note:";            this.notifyIcon1.Icon = ((System.Drawing.Icon)(resources.GetObject("notifyIcon1.Icon")));            this.notifyIcon1.Text = "Hello Demo";            this.notifyIcon1.Visible = true;            //             // Form1            //             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;            this.ClientSize = new System.Drawing.Size(292, 266);            this.MaximizeBox = false;            this.Name = "Form1";            this.Text = "Form1";            this.Load += new System.EventHandler(this.Form1_Load);            this.ResumeLayout(false);        }        #endregion        private System.Windows.Forms.NotifyIcon notifyIcon1;    }}using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;namespace WindowsApplication1{    public partial class Form1 : Form    {        public Form1()        {            InitializeComponent();        }        private void Form1_Load(object sender, EventArgs e)        {            this.notifyIcon1.ShowBalloonTip(2);        }    }}
[解决办法]
NotifyIcon.ShowBalloonTip 方法 (Int32)

注意:此方法在 .NET Framework 2.0 版中是新增的。

在任务栏中持续显示气球提示指定的时间。

要VS2005或以上版本才能用

[解决办法]
在csdn资源下载界面搜索DotNetBar6.0 .dll

在工具箱,右键->选择项...->选.net framwork组件选"浏览"->把dotnetbar6.0 .dll加入.
using DevComponents.DotNetBar;
form_load写入下面的代码就可以了.

C# code
         DevComponents.DotNetBar.Balloon b = new DevComponents.DotNetBar.Balloon();            b.Style = eBallonStyle.Alert;            Rectangle r = Screen.GetWorkingArea(this);            b.Location = new Point(r.Right - b.Width, r.Bottom - b.Height);            b.AutoClose = true;            b.AutoCloseTimeOut = 15;            b.Text = "abn\n423";            b.AlertAnimation = eAlertAnimation.BottomToTop;            b.AlertAnimationDuration = 300;            b.Show(false); 

读书人网 >C#

热点推荐