当前位置:编程学习 > C#/ASP.NET >>

怎么用C#创建一个中空的窗体

有没有人知道,用c# 创建自定窗体,需要客户区是一个相框形状的,就是中间是空的 c# 自定义窗体 --------------------编程问答-------------------- http://www.cnblogs.com/jxsoft/archive/2011/03/09/1978153.html --------------------编程问答-------------------- 给窗体设置一个背景色,然后设置窗体TransparencyKey属性和背景色一个颜色,然后窗体就是透明的了 --------------------编程问答-------------------- http://www.cnblogs.com/alexis/archive/2010/08/29/1811826.html --------------------编程问答-------------------- http://www.cnblogs.com/alexis/archive/2010/08/29/1811826.html  --------------------编程问答--------------------

public partial class Form1 : Form
{
    const int SC_MOVE = 0xF010;
    const int HTCAPTION = 0x0002;
    const int WM_SYSCOMMAND = 0x0112;
    [DllImport("user32.dll")]
    public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam);
    [DllImport("user32.dll")]
    public static extern bool ReleaseCapture();

    Bitmap bgImage;
    public Form1()
    {
        InitializeComponent();

        bgImage = Properties.Resources.pic;

        FormBorderStyle = FormBorderStyle.None;
        BackColor = Color.White;
        TransparencyKey = Color.White;
        Paint += new PaintEventHandler(Form1_Paint);
        MouseDown += new MouseEventHandler(Form1_MouseDown);
    }

    void Form1_MouseDown(object sender, MouseEventArgs e)
    {
        ReleaseCapture();
        SendMessage(Handle, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0);
    }

    void Form1_Paint(object sender, PaintEventArgs e)
    {
        e.Graphics.DrawImage(bgImage, 0, 0, bgImage.Width, bgImage.Height);
    }
}

补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,