| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 824 人关注过本帖
标题:C#程序模拟Vista界面效果
取消只看楼主 加入收藏
liujie164
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2007-8-7
收藏
 问题点数:0 回复次数:0 
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++
搜索更多相关主题的帖子: Vista 界面 效果 模拟 
2008-06-24 10:22
快速回复:C#程序模拟Vista界面效果
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.030118 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved