http://www.google.com/search?hl=zh-CN&newwindow=1&q=c%23+%E4%B8%8D%E8%A7%84%E5%88%99%E7%AA%97%E4%BD%93&lr=lang_zh-CN%7Clang_zh-TW

解决方案 »

  1.   

    调用API函数可以搞定(如:setwindowlong)
      

  2.   

    using System;
    using System.Drawing;
    using System.Collections;
    using System.ComponentModel;
    using System.Windows.Forms;
    using System.Data;
    using System.Drawing.Drawing2D;
    namespace abnormalForm
    {
    /// <summary>
    /// Form1 的摘要说明。
    /// </summary>
    public class Form1 : System.Windows.Forms.Form
    {
    private System.ComponentModel.IContainer components; public Form1()
    {
    //
    // Windows 窗体设计器支持所必需的
    //
    InitializeComponent(); //
    // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
    //
    } /// <summary>
    /// 清理所有正在使用的资源。
    /// </summary>
    protected override void Dispose( bool disposing )
    {
    if( disposing )
    {
    if (components != null) 
    {
    components.Dispose();
    }
    }
    base.Dispose( disposing );
    } #region Windows 窗体设计器生成的代码
    /// <summary>
    /// 设计器支持所需的方法 - 不要使用代码编辑器修改
    /// 此方法的内容。
    /// </summary>
    private void InitializeComponent()
    {
    this.components = new System.ComponentModel.Container();
    System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
    this.label1 = new System.Windows.Forms.Label();
    this.imageList1 = new System.Windows.Forms.ImageList(this.components);
    this.label2 = new System.Windows.Forms.Label();
    this.label3 = new System.Windows.Forms.Label();
    this.SuspendLayout();
    // 
    // label1
    // 
    this.label1.BackColor = System.Drawing.Color.Black;
    this.label1.ImageIndex = 1;
    this.label1.ImageList = this.imageList1;
    this.label1.Location = new System.Drawing.Point(130, 121);
    this.label1.Name = "label1";
    this.label1.Size = new System.Drawing.Size(18, 18);
    this.label1.TabIndex = 0;
    this.label1.MouseUp += new System.Windows.Forms.MouseEventHandler(this.label1_MouseUp);
    this.label1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.label1_MouseDown);
    // 
    // imageList1
    // 
    this.imageList1.ImageSize = new System.Drawing.Size(18, 18);
    this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream")));
    this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
    // 
    // label2
    // 
    this.label2.BackColor = System.Drawing.Color.Black;
    this.label2.ImageIndex = 4;
    this.label2.ImageList = this.imageList1;
    this.label2.Location = new System.Drawing.Point(309, 121);
    this.label2.Name = "label2";
    this.label2.Size = new System.Drawing.Size(18, 18);
    this.label2.TabIndex = 1;
    this.label2.MouseUp += new System.Windows.Forms.MouseEventHandler(this.label2_MouseUp);
    this.label2.MouseDown += new System.Windows.Forms.MouseEventHandler(this.label2_MouseDown);
    // 
    // label3
    // 
    this.label3.BackColor = System.Drawing.Color.Black;
    this.label3.ImageIndex = 2;
    this.label3.ImageList = this.imageList1;
    this.label3.Location = new System.Drawing.Point(328, 121);
    this.label3.Name = "label3";
    this.label3.Size = new System.Drawing.Size(18, 18);
    this.label3.TabIndex = 2;
    this.label3.MouseUp += new System.Windows.Forms.MouseEventHandler(this.label3_MouseUp);
    this.label3.MouseDown += new System.Windows.Forms.MouseEventHandler(this.label3_MouseDown);
    // 
    // Form1
    // 
    this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
    this.BackColor = System.Drawing.Color.White;
    this.ClientSize = new System.Drawing.Size(456, 482);
    this.Controls.Add(this.label3);
    this.Controls.Add(this.label2);
    this.Controls.Add(this.label1);
    this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
    this.Name = "Form1";
    this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
    this.Text = "Form1";
    this.TransparencyKey = System.Drawing.Color.White;
    this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.Form1_MouseDown);
    this.MouseUp += new System.Windows.Forms.MouseEventHandler(this.Form1_MouseUp);
    this.Paint += new System.Windows.Forms.PaintEventHandler(this.Form1_Paint);
    this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.Form1_MouseMove);
    this.ResumeLayout(false); }
    #endregion /// <summary>
    /// 应用程序的主入口点。
    /// </summary>
    [STAThread]
    static void Main() 
    {
    Application.Run(new Form1());
    }
      

  3.   

    private Point mouseOffset;
    private bool isMouseDown = false;
    Point[] pMainExpand = new Point[16]{
       new Point(127, 1),
       new Point(352, 1),
       new Point(352, 107),
       new Point(372, 128),
       new Point(452, 128),
       new Point(452, 354),
       new Point(372, 354),
       new Point(352, 374),
       new Point(352, 480),
       new Point(127, 480),
       new Point(127, 373),
       new Point(107, 353),
       new Point(1, 354),
       new Point(1, 128),
       new Point(107, 128),
       new Point(127, 107)
       };
    Point[] pMainCollapse = new Point[8]{
     new Point(352, 107),
     new Point(372, 128),
     new Point(372, 354),
     new Point(352, 374),
     new Point(127, 373),
     new Point(107, 353),
     new Point(107, 128),
     new Point(127, 107)
     };
    private System.Windows.Forms.Label label1;
    private System.Windows.Forms.ImageList imageList1;
    private System.Windows.Forms.Label label2;
    private System.Windows.Forms.Label label3; bool IsExpand = false; Graphics g;// = new Graphics();
    Image image = new Bitmap(@"..\..\normal.bmp");
    TextureBrush tBrush; private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
    {
    g = this.CreateGraphics();
    //画多边形
    //SolidBrush sb0 = new SolidBrush(Color.FromArgb(12, 98, 175));
    //g.FillPolygon(sb0, pMain);
    //画一个字
    //g.DrawString("C#", new Font(Font.FontFamily.Name, 120), new SolidBrush(Color.Red), 0, 0);
    //用图像填充
    tBrush = new TextureBrush(image);
    tBrush.WrapMode = WrapMode.TileFlipXY;
    g.FillPolygon(tBrush, pMainCollapse);
    } private void Form1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
    {
    int xOffset;
    int yOffset; if (e.Button == MouseButtons.Left) 
    {
    xOffset = -e.X - SystemInformation.FrameBorderSize.Width;
    yOffset = -e.Y - SystemInformation.CaptionHeight - 
    SystemInformation.FrameBorderSize.Height;
    mouseOffset = new Point(xOffset, yOffset);
    isMouseDown = true;
    }
    } private void Form1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
    {
    if (isMouseDown) 
    {
    Point mousePos = Control.MousePosition;
    mousePos.Offset(mouseOffset.X+4, mouseOffset.Y+23);
    Location = mousePos;
    }
    } private void Form1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
    {
    // Changes the isMouseDown field so that the form does
    // not move unless the user is pressing the left mouse button.
    if (e.Button == MouseButtons.Left) 
    {
    isMouseDown = false;
    }
    } private void label1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
    {
    label1.ImageIndex = 0;
    } private void label1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
    {
    label1.ImageIndex = 1;
    if(!IsExpand)
    {
    g.FillPolygon(tBrush, pMainExpand);
    IsExpand = true;
    }
    else
    {
    g.FillPolygon(tBrush, pMainCollapse);
    IsExpand =false;
    this.Refresh();
    }
    } private void label2_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
    {
    label2.ImageIndex = 5;
    } private void label2_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
    {
    label2.ImageIndex = 4;
    this.WindowState = FormWindowState.Minimized;
    } private void label3_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
    {
    label3.ImageIndex = 3;
    } private void label3_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
    {
    label3.ImageIndex = 2;
    Application.Exit();
    }
    }
    }