C#實現帶消息數的App圖標
上次寫了一篇博文,但是每次更新圖標時,桌面會閃爍(刷新)//www.jb51.net/article/73350.htm,有博友說人家的圖標都不會刷新,還能動畫.我想了一下,如果要達到這個效果,可以用Form來實現,就是在Form中嵌入一個圖片,然后用一個label來動態(tài)顯示消息數,關鍵是將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#代碼實現對AES加密解密
欄 目:C#教程
本文標題:C#實現帶消息數的App圖標
本文地址:http://www.jygsgssxh.com/a1/C_jiaocheng/6783.html
您可能感興趣的文章
- 01-10C#實現txt定位指定行完整實例
- 01-10WinForm實現仿視頻播放器左下角滾動新聞效果的方法
- 01-10C#實現清空回收站的方法
- 01-10C#實現讀取注冊表監(jiān)控當前操作系統(tǒng)已安裝軟件變化的方法
- 01-10C#實現多線程下載文件的方法
- 01-10C#實現Winform中打開網頁頁面的方法
- 01-10C#實現遠程關閉計算機或重啟計算機的方法
- 01-10C#自定義簽名章實現方法
- 01-10C#文件斷點續(xù)傳實現方法
- 01-10winform實現創(chuàng)建最前端窗體的方法


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


