C # How to Implement the App icon with the number of messages,
I wrote a blog post last time, but every time I update the icon, the desktop will flash (refresh). Some bloggers say that the icons of other people will not be refreshed and can still be animated. I thought for a moment, if you want to achieve this effect, you can use Form to implement it, that is, embed an image in Form, and then use a label to dynamically display the number of messages, the key is to hide the Form border and set the background to transparent. if you want to rotate or scale an animation, you can use C.
1 using System; 2 using System. collections. generic; 3 using System. componentModel; 4 using System. data; 5 using System. drawing; 6 using System. linq; 7 using System. text; 8 using System. windows. forms; 9 10 namespace AOPDemo11 {12 public partial class AppIconMsg: Form13 {14 public AppIconMsg () 15 {16 InitializeComponent (); 17 // set the background to transparent 18 this. backColor = Color. fromArgb (116,164, 2); 19 this. transparencyKey = this. backColor; 20 21} 22 23 private void AppIconMsg_Load (object sender, EventArgs e) 24 {25 this. width = 64; 26 this. height = 64; 27 this. label1.Text = "99"; 28 this. timer1.Enabled = true; 29 30} 31 32 // Drag it around the screen33 private const int WM_NCHITTEST = 0x84; 34 private const int HTCAPTION = 0x2; 35 protected override void WndProc (ref Message m) 36 {37 // Disable mouseDoubleClick on form38 if (m. msg = WM_LBUTTONDBLCLK) 39 {40 Form2 frm = new Form2 (msg); 41 frm. show (); 42 // this. close (); 43 return; 44} 45 46 if (m. msg = WM_NCLBUTTONDBLCLK) 47 {48 Form2 frm = new Form2 (msg); 49 frm. show (); 50 // this. close (); 51 return; 52} 53 54 // drag55 if (m. msg = WM_NCHITTEST) 56 m. result = new IntPtr (HTCAPTION); 57 else58 base. wndProc (ref m); 59} 60 private int msg = 0; 61 private void timer1_Tick (object sender, EventArgs e) 62 {63 int num = new Random (). next (1,100); 64 msg = num; 65 this. label1.Text = num. toString (); 66} 67 68 const int WM_LBUTTONDBLCLK = 0x0203; // client area69 const int prior = 0x00A3; // non-client area70 private void toolStripExit_Click (object sender, eventArgs e) 71 {72 this. close (); 73} 74 75} 76}