http://www.01study.com/resource/viewfile.asp?id=1339

解决方案 »

  1.   

    卢彦(MVP)有一篇文章http://www.microsoft.com/china/community/Column/60.mspx
      

  2.   


    孟子E章兄:http://www.01study.com/resource/viewfile.asp?id=1339怎么打不开啊?
      

  3.   

    用C#.net轻松制作不规则窗体(附源码)
    http://www.01study.com/resource/tutorials/20039814304174869.rar绘制不规则窗体位图 
            可以使用任意一种你喜欢的作图工具,制作一个有形状的位图,背景使用一种其他的颜色。这个颜色在编程中用得着,所以最好使用一种容易记忆的颜色。
    如图下图,本例中使用的背景色为黄色(#ffff00/yellow),文件名为bk.bmp
        2.创建windows窗体并设置窗体基本属性
            1>新建windows应用程序
            2>选中新建的窗体,设置其相应属性:
                    (1)。将 FormBorderStyle 属性设置为 None。
                    (2)。将窗体的 BackgroundImage 属性设置为先前创建的位图文件。不必将文件添加到项目系统中;这将在指定该文件作为背景图像时自动完成。
                    (3)。将 TransparencyKey 属性设置为位图文件的背景色,本例中为黄色。(此属性告诉应用程序窗体中的哪些部分需要设置为透明。 )
             这时你就可以按F5测试你的程序,可以看到如图所示的窗体。现在窗体还不能拖动,只能通过结束程序,或者alt+F4关闭。下面我们编写相应的代码来实现标题栏的相应功能。       
        3.编写窗体相关代码
            (要实现窗口的关闭,移动等操作)
             
            (1)。实现窗口关闭
                    从工具栏中拖进一个按钮,设置其按钮文字为“×”,设置其大小为合适大小。双击该按钮进入其触发时间函数。
                    写入如下代码:
                            
                    this.Close();        //关闭本窗体        (2)。设置窗体的移动操作,我们要用到两个全局的变量
                    private Point mouseOffset;        //记录鼠标指针的坐标
                    private bool isMouseDown = false; //记录鼠标按键是否按下                创建该窗体 MouseDown事件的相应处理程序。
                    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;
                            }
                    }
                    创建该窗体的 MouseMove事件的相应处理程序
                    private void Form1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
                    {
                            if (isMouseDown) 
                            {
                                    Point mousePos = Control.MousePosition;
                                    mousePos.Offset(mouseOffset.X, mouseOffset.Y);
                                    Location = mousePos;
                            }
                    }
                    
                    创建该窗体的MouseUp事件的相应处理程序
                    private void Form1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
                    {
                            // 修改鼠标状态isMouseDown的值
                            // 确保只有鼠标左键按下并移动时,才移动窗体
                            if (e.Button == MouseButtons.Left) 
                            {
                                    isMouseDown = false;
                            }
                    }        (3)。加入相应的其他的控件
                       其他的就是看你自己的需要,来添加控件,实现自己想要实现的功能。
                       本例中添加了一文本框,设置其背景为黄色,所以显示时也成了透明的。
            
             现在,我们就可以生成程序,看一下最后的效果了。注意:如果监视器的颜色深度设置大于 24 位,则不管 TransparencyKey 属性是如何设置的,窗体的非透明部分都会产生显示问题。若要避免出现这种问题,请确保“显示”控制面板中的监视器颜色深度的设置小于 24 位。当开发具有这种透明功能的应用程序时,请牢记应使您的用户意识到此问题。
      

  4.   

    实现步骤:
    1.formBorderStyle设为none之后,怎么让鼠标托动窗体? 
      参考:http://expert.csdn.net/Expert/topic/2938/2938210.xml?temp=.8810083
      在鼠标拖动窗体时若要显示虚框,跟操作系统设置有关:
      在桌面单击右键 ->属性 ->效果 把拖动时显示窗口内容 不选时有虚框出现。
    2.FormBorderStyle =None的情况下如何实现拖动窗口边缘改变窗口大小 
      在工具箱里找到splitter控件,拖到窗体上,设置dock属性为right,name为
      需要添加三个事件:
      this.splitterRight.MouseUp += new System.Windows.Forms.MouseEventHandler(this.splitterRight_MouseUp);
      this.splitterRight.MouseMove += new System.Windows.Forms.MouseEventHandler(this.splitterRight_MouseMove);
      this.splitterRight.MouseDown += new System.Windows.Forms.MouseEventHandler(this.splitterRight_MouseDown);
      private bool flagMove=false;
      //左键按下时,设置可移动
      private void splitterRight_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
      {
    this.flagMove = true;

      }
      //右边移动
      private void splitterRight_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
      {
    if(this.flagMove  )
            {
    this.Width = this.Width +e.X ;
    }
      }
      //左键松开时,设置不可移动
      private void splitterRight_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
      {
    this.flagMove = false;
      }
    3.添加三个label控件,实现最小化,最大化,关闭按钮
      //最小化按钮
    private void labelMin_Click(object sender, System.EventArgs e)
    {
    this.WindowState = FormWindowState.Minimized ;
    }
    //最大化及还原按钮
    private void labelMax_Click(object sender, System.EventArgs e)
    {
      
    if(this.WindowState ==FormWindowState.Maximized  )
    {
    this.WindowState = FormWindowState.Normal ;
    }
    else
    {
    this.WindowState = FormWindowState.Maximized ;
    }
    }
    //关闭按钮
    private void labelclose1_Click(object sender, System.EventArgs e)
    {
    this.Close();
    this.Dispose();
    }4.加上你所要的背景图片即可
      

  5.   

    大的图片很占内存,可用pictrueBox代替
    Bitmap MyImage = new Bitmap(@"D:\图片\top.bmp");
    //设置图片能够自适应的
    this.pictureBoxTop.SizeMode = PictureBoxSizeMode.StretchImage;
    this.pictureBoxTop.Image  = MyImage;