VC# 将窗体外观设置为自己画的多边形图案

2024-11-25 07:23:06
推荐回答(2个)
回答1:

把窗体背景色换成特殊颜色(如蓝色)

然后给窗体背景设置一个图片(如设置一个小企鹅)

然后设置窗体的透明颜色为蓝色,

然后把窗体设置为没有边框,

如下图:

回答2:

请参考:
[DllImport("gdi32")]
private static extern IntPtr CreatePolygonRgn(Point[] lpPoint,int nCount,int nPolyFillMode);
[DllImport("user32")]
private static extern IntPtr SetWindowRgn(IntPtr hWnd,IntPtr hRgn,bool bRedraw);
const int WINDING = 2;
private void Form1_Load(object sender, System.EventArgs e)
{
Point[] pt={
new Point(this.Width /2,0),
new Point(0,this.Height/2),
new Point(this.Width/2,this.Height),
new Point(this.Width,this.Height/2),
new Point(this.Width,0)
};

IntPtr m_rgn;
m_rgn=CreatePolygonRgn(pt,5,WINDING);
SetWindowRgn(this.Handle,m_rgn,true);
}