C#程序模拟Vista界面效果
using System; using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace Vista
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.SetStyle(ControlStyles.AllPaintingInWmPaint|ControlStyles.OptimizedDoubleBuffer|ControlStyles.UserPaint,true);
this.SetStyle(ControlStyles.SupportsTransparentBackColor,true);
}
private const int WM_NCHITTEST = 0x84;//132
private const int HTCLIENT = 0x1;//1
private const int HTCAPTION = 0x2;//2
protected override void WndProc(ref Message m)
{
switch (m.Msg)
{
case WM_NCHITTEST:
base.WndProc(ref m);
if ((int)m.Result == HTCLIENT)//1
m.Result = (IntPtr)HTCAPTION;//2
return;
break;
}
base.WndProc(ref m);
}
private Bitmap topleft = new Bitmap(System.AppDomain.CurrentDomain.BaseDirectory+"top_left.png");
private Bitmap topmiddle = new Bitmap(System.AppDomain.CurrentDomain.BaseDirectory+"top.png");
private Bitmap topright = new Bitmap(System.AppDomain.CurrentDomain.BaseDirectory+"top_right.png");
private Bitmap left = new Bitmap(System.AppDomain.CurrentDomain.BaseDirectory+"left.png");
private Bitmap right = new Bitmap(System.AppDomain.CurrentDomain.BaseDirectory+"right.png");
private Bitmap bottomleft = new Bitmap(System.AppDomain.CurrentDomain.BaseDirectory+"bottom_left.png");
private Bitmap bottommiddle = new Bitmap(System.AppDomain.CurrentDomain.BaseDirectory+"bottom.png");
private Bitmap bottomright = new Bitmap(System.AppDomain.CurrentDomain.BaseDirectory + "bottom_right.png");
private Image img;
protected override void OnPaint(PaintEventArgs e)
{
Graphics g = Graphics.FromImage(img);
g.Clear(Color.Black);
g.CopyFromScreen(new Point(0,0),new Point(0,0),Screen.AllScreens[0].Bounds.Size,CopyPixelOperation.SourcePaint);
Rectangle rectel = new Rectangle(0,0,this.Width,this.Height);
Rectangle rec = new Rectangle(this.Location,this.Size);
Bitmap bit = new Bitmap(this.Width,this.Height);
Graphics grafic = Graphics.FromImage(bit);
grafic.DrawImage(img,rectel,rec,GraphicsUnit.Pixel);
BackgroundImage = bit;
e.Graphics.DrawImage(topleft,new Rectangle(0,0,topleft.Width,topleft.Height),0,0,topleft.Width,topleft.Height,GraphicsUnit.Pixel);
e.Graphics.DrawImage(topmiddle,topleft.Width,0,Width-topleft.Width-topright.Width+1,topmiddle.Height);
e.Graphics.DrawImage(topright,Width-topright.Width,0,topright.Width,topright.Height);
e.Graphics.DrawImage(left,0,topleft.Height,left.Width,Height-topleft.Height-bottomleft.Height);
e.Graphics.DrawImage(right,Width-topright.Width,topright.Height,right.Width,Height-topright.Height-bottomright.Height);
e.Graphics.DrawImage(bottomleft,0,Height-bottomleft.Height,bottomleft.Width,bottomleft.Height);
e.Graphics.DrawImage(bottommiddle,bottomleft.Width,Height-bottommiddle.Height,Width-bottomleft.Width-bottomright.Width+1,bottommiddle.Height);
e.Graphics.DrawImage(bottomright,Width-bottomright.Width,Height-bottomright.Height,bottomright.Width,bottomright.Height);
e.Dispose();
// base.OnPaint(e);
}
protected override void OnLoad(EventArgs e)
{
img = new Bitmap(Screen.AllScreens[0].Bounds.Width,Screen.AllScreens[0].Bounds.Height);
//base.OnLoad(e);
}
}
}" border="0" />
本人新建群25376219,大量召集高手,非程序人员勿挠,只讨论,C#,Java,c++,C,SQL server,Oracle,本人所会Java,C#.Net,JavaWeb,SQL server 正在学的有和C++