<转载>C# 通过API改变窗体形状

using System.Runtime.InteropServices;
[DllImportAttribute ("gdi32.dll")] 
public static extern IntPtr CreateRoundRectRgn(int nLeftRect,int nTopRect,int nRightRect,int nBottomRect,int nWidthEllipse,int nHeightEllipse);
[DllImportAttribute ("user32.dll")]
public static extern int SetWindowRgn(IntPtr hWnd,IntPtr hRgn, bool bRedraw);

Fom1 fl = new Form1();
IntPtr regionHandle =CreateRoundRectRgn(0,0,fl.Width,fl.Height,20,20);
Region roundRegion = null;
roundRegion = Region.FromHrgn(regionHandle);
SetWindowRgn(Handle,regionHandle,true);
posted @ 2011-07-05 16:28  孤獨龍  阅读(462)  评论(0编辑  收藏  举报