C#实现带消息数的App图标
更新时间:2015年12月10日 08:58:28 投稿:hebedich
这篇文章主要介绍了如何使用C#实现带消息数的App图标的方法,并附上全部源码,分享给大家,有需要的小伙伴可以参考下。
上次写了一篇博文,但是每次更新图标时,桌面会闪烁(刷新)https://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(); } } }
相关文章
DirectInfo.GetFiles返回数组的默认排序示例
这篇文章主要介绍了,DirectInfo.GetFiles返回数组的默认排序示例NTFS和CDFS下,是按照字母顺序,而FAT下,按照文件创建时间顺序2014-01-01C#正则表达式分解和转换IP地址实例(C#正则表达式大全 c#正则表达式语法)
这是我发了不少时间整理的C#的正则表达式,新手朋友注意一定要手册一下哦,这样可以节省很多写代码的时间。下面进行了简单总结2013-12-12WinForm使用DecExpress控件中的ChartControl插件绘制图表
这篇文章介绍了WinForm使用DecExpress控件中的ChartControl插件绘制图表的方法,文中通过示例代码介绍的非常详细。对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下2022-05-05C#使用ToUpper()与ToLower()方法将字符串进行大小写转换的方法
这篇文章主要介绍了C#使用ToUpper()与ToLower()方法将字符串进行大小写转换的方法,实例分析了C#大小写转换的相关技巧,需要的朋友可以参考下2015-04-04
最新评论