一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

DotNet中不规则窗体的创建方法

时间:2008-01-12 编辑:简简单单 来源:一聚教程网

ShapedForms
http://www.c-sharpcorner.com/Graphics/Shaped1.jpg

Today Windows always appear with a rectangular shape. What if you could have a window that was shaped like a circle, a square or a triangle or any shape you want.
I discovered tonight you could use regions to in effect clip a window to any shape you want. The effect is almost to look like an active desktop component as you cannot move these shaped windows. Having done this and created some animation on your desktop I wonder if you could load a bitmap as the basis for your windows. Note you lose the titlebars etc but it looks like a useful technique.
Here is the source code. Apologies if its messy but its been a long night searching for how to do this. I have attached the exe as well for Beta 2
Enjoy
John
Source Code:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Drawing.Drawing2D;
namespace ShapedForm
{
        ///
        /// Summary description for Form1.
        ///

        public class Form1 : System.Windows.Forms.Form
        {
       private System.Windows.Forms.Timer timer1;
       private System.ComponentModel.IContainer components;

热门栏目