C#實現(xiàn)帶消息數(shù)的App圖標
上次寫了一篇博文,但是每次更新圖標時,桌面會閃爍(刷新)http://www.dbjr.com.cn/article/73350.htm,有博友說人家的圖標都不會刷新,還能動畫.我想了一下,如果要達到這個效果,可以用Form來實現(xiàn),就是在Form中嵌入一個圖片,然后用一個label來動態(tài)顯示消息數(shù),關(guān)鍵是將Form的邊框隱藏,背景設(shè)為透明即可.如果要有旋轉(zhuǎn)或者縮放動畫,都可以用C#來實現(xiàn).
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(); //設(shè)置背景為透明 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#向無窗口的進程發(fā)送消息
- C#微信開發(fā)之接收 / 返回文本消息
- C#記錄消息到日志文件的方法
- C# WinForm應(yīng)用程序降低系統(tǒng)內(nèi)存占用方法總結(jié)
- c#取得控制臺應(yīng)用程序根目錄
- C# 禁止應(yīng)用程序多次啟動的實例
- C#Web應(yīng)用程序入門經(jīng)典學(xué)習(xí)筆記之二
- C#實現(xiàn)將應(yīng)用程序設(shè)置為開機啟動的方法
- C#Web應(yīng)用程序入門經(jīng)典學(xué)習(xí)筆記之一
- C#使用windows服務(wù)開啟應(yīng)用程序的方法
- C#實現(xiàn)在應(yīng)用程序間發(fā)送消息的方法示例
相關(guān)文章
DirectInfo.GetFiles返回數(shù)組的默認排序示例
這篇文章主要介紹了,DirectInfo.GetFiles返回數(shù)組的默認排序示例NTFS和CDFS下,是按照字母順序,而FAT下,按照文件創(chuàng)建時間順序2014-01-01C#正則表達式分解和轉(zhuǎn)換IP地址實例(C#正則表達式大全 c#正則表達式語法)
這是我發(fā)了不少時間整理的C#的正則表達式,新手朋友注意一定要手冊一下哦,這樣可以節(jié)省很多寫代碼的時間。下面進行了簡單總結(jié)2013-12-12WinForm使用DecExpress控件中的ChartControl插件繪制圖表
這篇文章介紹了WinForm使用DecExpress控件中的ChartControl插件繪制圖表的方法,文中通過示例代碼介紹的非常詳細。對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下2022-05-05C#使用ToUpper()與ToLower()方法將字符串進行大小寫轉(zhuǎn)換的方法
這篇文章主要介紹了C#使用ToUpper()與ToLower()方法將字符串進行大小寫轉(zhuǎn)換的方法,實例分析了C#大小寫轉(zhuǎn)換的相關(guān)技巧,需要的朋友可以參考下2015-04-04