窗体浮动

 1 private void Form1_Load(object sender, EventArgs e)
2 {
3
4 }
5 private int screenWidth;//屏幕宽度
6 private int screenHeight;//屏幕高度
7 private bool isUp = true;//是否完全显示提示窗口
8
9 public void init()
10 {
11 screenHeight = Screen.PrimaryScreen.Bounds.Height;
12 screenWidth = Screen.PrimaryScreen.Bounds.Width;
13 //设置提示窗口坐标在屏幕可显示区域之外
14 Location = new Point(screenWidth - Width, screenHeight);
15 StartPosition = FormStartPosition.Manual;
16 timer1.Start();
17 textBox1.Text = "";
18 //Class1.sendEvent += new Class1.SendMessage(this.DoMethod);
19
20 }
21 private void timer1_Tick(object sender, EventArgs e)
22 {
23 if (isUp)//如果提示窗口没有完全显示
24 {
25 if (Location.Y > 0)
26 {
27 Location = new Point(Location.X, Location.Y - 5);
28 }
29 else
30 {
31 isUp = false;
32 }
33 ////如果提示窗口的纵坐标与提示窗口的高度之和大于屏幕高度
34 //if (Location.Y + Height >= screenHeight)
35 //{
36 // Location = new Point(Location.X, Location.Y - 5);
37 //}
38 //else
39 //{
40 // // timer1.Stop();
41 //}
42 }
43 else//如果提示窗口已经完成了显示,并且点击了确定按钮
44 {
45 //如果提示窗口没有完全从屏幕上消失
46 if (Location.Y+Height < screenHeight)
47 {
48 Location = new Point(Location.X, Location.Y + 5);
49 }
50 else
51 {
52 isUp = true;
53 }
54 }
55 }
56
57 private void Form1_MouseEnter(object sender, EventArgs e)
58 {
59 timer1.Stop();
60 }
61
62 private void Form1_MouseLeave(object sender, EventArgs e)
63 {
64 timer1.Start();
65 }
66
67 private void button1_Click(object sender, EventArgs e)
68 {
69 this.Dispose();
70 this.Close();
71 }
72
73 private void button1_MouseEnter(object sender, EventArgs e)
74 {
75 timer1.Stop();
76 }
77 public void DoMethod(string getstr)
78 {
79 textBox1.Text += getstr;
80 }
81
82 private void textBox1_MouseEnter(object sender, EventArgs e)
83 {
84 timer1.Stop();
85 }



转载于:https://www.cnblogs.com/IT-Bear/archive/2012/02/09/2343995.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值