上次写了一篇博文,但是每次更新图标时,桌面会闪烁(刷新),有博友说人家的图标都不会刷新,还能动画.我想了一下,如果要达到这个效果,可以用form来实现,就是在form中嵌入一个图片,然后用一个label来动态显示消息数,关键是将form的边框隐藏,背景设为透明即可.如果要有旋转或者缩放动画,都可以用c#来实现.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
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();
}
}
}
|