手机
当前位置:查字典教程网 >编程开发 >C#教程 >C#实现带消息数的App图标
C#实现带消息数的App图标
摘要:上次写了一篇博文,但是每次更新图标时,桌面会闪烁(刷新)http://www.jb51.net/article/73350.htm,有博友说...

上次写了一篇博文,但是每次更新图标时,桌面会闪烁(刷新)http://www.jb51.net/article/73350.htm,有博友说人家的图标都不会刷新,还能动画.我想了一下,如果要达到这个效果,可以用Form来实现,就是在Form中嵌入一个图片,然后用一个label来动态显示消息数,关键是将Form的边框隐藏,背景设为透明即可.如果要有旋转或者缩放动画,都可以用C#来实现.

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace AOPDemo { public partial class AppIconMsg : Form { public AppIconMsg() { InitializeComponent(); //设置背景为透明 this.BackColor = Color.FromArgb(116, 164, 2); this.TransparencyKey = this.BackColor; } private void AppIconMsg_Load(object sender, EventArgs e) { this.Width = 64; this.Height = 64; this.label1.Text = "99"; this.timer1.Enabled = true; } // Drag it around the screen private const int WM_NCHITTEST = 0x84; private const int HTCAPTION = 0x2; protected override void WndProc(ref Message m) { //Disable mouseDoubleClick on form if (m.Msg == WM_LBUTTONDBLCLK) { Form2 frm = new Form2(msg); frm.Show(); //this.Close(); return; } if (m.Msg == WM_NCLBUTTONDBLCLK) { Form2 frm = new Form2(msg); frm.Show(); // this.Close(); return; } //drag if (m.Msg == WM_NCHITTEST) m.Result = new IntPtr(HTCAPTION); else base.WndProc(ref m); } private int msg = 0; private void timer1_Tick(object sender, EventArgs e) { int num = new Random().Next(1, 100); msg = num; this.label1.Text = num.ToString(); } const int WM_LBUTTONDBLCLK = 0x0203;//client area const int WM_NCLBUTTONDBLCLK = 0x00A3;//non-client area private void toolStripExit_Click(object sender, EventArgs e) { this.Close(); } } }

C#实现带消息数的App图标1

C#实现带消息数的App图标2

【C#实现带消息数的App图标】相关文章:

深入Resource实现多语言支持的应用详解

C#中静态的深入理解

C#实现对AES加密和解密的方法

C# IP地址与整数之间转换的具体方法

C#实现写入与读出文本文件的实例代码

c#实现输出本月的月历

C#实现任意数据类型转成json格式输出

使用C#实现在屏幕上画图效果的代码实例

使用C#实现阿拉伯数字到大写中文的转换

用C#生成不重复的随机数的代码

精品推荐
分类导航