C#實現(xiàn)帶消息數(shù)的App圖標
上次寫了一篇博文,但是每次更新圖標時,桌面會閃爍(刷新)//www.jb51.net/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(); } } }
您可能感興趣的文章
- 01-10C#實現(xiàn)txt定位指定行完整實例
- 01-10WinForm實現(xiàn)仿視頻播放器左下角滾動新聞效果的方法
- 01-10C#實現(xiàn)清空回收站的方法
- 01-10C#實現(xiàn)讀取注冊表監(jiān)控當(dāng)前操作系統(tǒng)已安裝軟件變化的方法
- 01-10C#實現(xiàn)多線程下載文件的方法
- 01-10C#實現(xiàn)Winform中打開網(wǎng)頁頁面的方法
- 01-10C#實現(xiàn)遠程關(guān)閉計算機或重啟計算機的方法
- 01-10C#自定義簽名章實現(xiàn)方法
- 01-10C#文件斷點續(xù)傳實現(xiàn)方法
- 01-10winform實現(xiàn)創(chuàng)建最前端窗體的方法


閱讀排行
本欄相關(guān)
- 01-10C#通過反射獲取當(dāng)前工程中所有窗體并
- 01-10關(guān)于ASP網(wǎng)頁無法打開的解決方案
- 01-10WinForm限制窗體不能移到屏幕外的方法
- 01-10WinForm繪制圓角的方法
- 01-10C#實現(xiàn)txt定位指定行完整實例
- 01-10WinForm實現(xiàn)仿視頻播放器左下角滾動新
- 01-10C#停止線程的方法
- 01-10C#實現(xiàn)清空回收站的方法
- 01-10C#通過重寫Panel改變邊框顏色與寬度的
- 01-10C#實現(xiàn)讀取注冊表監(jiān)控當(dāng)前操作系統(tǒng)已
隨機閱讀
- 08-05DEDE織夢data目錄下的sessions文件夾有什
- 01-11Mac OSX 打開原生自帶讀寫NTFS功能(圖文
- 01-10SublimeText編譯C開發(fā)環(huán)境設(shè)置
- 08-05dedecms(織夢)副欄目數(shù)量限制代碼修改
- 01-11ajax實現(xiàn)頁面的局部加載
- 08-05織夢dedecms什么時候用欄目交叉功能?
- 01-10使用C語言求解撲克牌的順子及n個骰子
- 01-10C#中split用法實例總結(jié)
- 04-02jquery與jsp,用jquery
- 01-10delphi制作wav文件的方法