文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>给窗体加个圣诞帽——抛砖引玉

给窗体加个圣诞帽——抛砖引玉

时间:2010-12-15  来源:MNight

 

代码
 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 using System.Runtime.InteropServices;
10
11 namespace Hat
12 {
13 public partial class Form1 : Form
14 {
15 FrmHat hat = new FrmHat();
16
17 [DllImport("user32.dll", EntryPoint = "GetForegroundWindow")]
18 public static extern IntPtr GetForegroundWindow();
19
20 [DllImport("user32.dll")]
21 [return: MarshalAs(UnmanagedType.Bool)]
22 static extern bool GetWindowRect(IntPtr hWnd, ref RECT lpRect);
23
24 public Form1()
25 {
26 InitializeComponent();
27 hat.Location = new Point(this.Location.X - 30, this.Location.Y - 10);
28 hat.Show();
29 }
30
31
32 [StructLayout(LayoutKind.Sequential)]
33 public struct RECT
34 {
35 public int Left; //最左坐标
36 public int Top; //最上坐标
37 public int Right; //最右坐标
38 public int Bottom; //最下坐标
39 }
40
41 private void timer1_Tick(object sender, EventArgs e)
42 {
43 IntPtr ip = GetForegroundWindow();
44 RECT rect = new RECT();
45 GetWindowRect(ip, ref rect);
46
47 hat.Location = new Point(rect.Left - 30,rect.Top - 10);
48 }
49 }
50 }
51

 

 

 

 

弄个圣诞老人在桌面上乱跳也是不错的,不过没时间弄了。

下载地址:http://download.csdn.net/source/2911302

相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载