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

