.NET下设计各种形状的窗体界面

来源:互联网 发布:免费淘宝客cms 编辑:程序博客网 时间:2024/04/30 12:49
下列代码功能是改变当前窗体形状为椭圆形:
 Dim P As System.Drawing.Drawing2D.GraphicsPath = New System.Drawing.Drawing2D.GraphicsPath ( )
 P.AddEllipse ( 0 , 0 ,  Me.ClientSize.Width,  Me.ClientSize.Height)
 Me.Region = New Region ( P )

下列代码功能是改变当前窗体形状为扇形:
  Dim P As System.Drawing.Drawing2D.GraphicsPath = New System.Drawing.Drawing2D.GraphicsPath ( )
  P.AddPie ( 10 , 10 , 200 , 200 , 5 , 150 )
  Me.Region = New Region ( P )

下列代码功能是改变当前窗体形状为环形:
  Dim P As System.Drawing.Drawing2D.GraphicsPath = New System.Drawing.Drawing2D.GraphicsPath ( )
 Dim Height As Integer = Me.ClientSize.Height
 Dim width As Integer = 80
 P.AddEllipse ( 0 , 0 , Height , Height )
 P.AddEllipse ( width , width , Height - ( width * 2 ) , Height - ( width * 2 ) )
 Me.Region = New Region ( P )

其实只要把Me.Region重定义个New Region(GraphicsPath)即可改变窗体形状,大家也可以试试改成别的形状的窗体!