winform創(chuàng)建不規(guī)則窗體的方法
本文實(shí)例講述了winform創(chuàng)建不規(guī)則窗體的方法。分享給大家供大家參考。具體如下:
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using Microsoft.Win32; using System.Drawing.Drawing2D; using System.IO; namespace WindowsApplication2 { public partial class Form3 : Form { public Form3() { InitializeComponent(); this.FormBorderStyle = FormBorderStyle.None; ColorConverter colorconvert = new ColorConverter(); this.BackColor = (Color)colorconvert.ConvertFromString("window"); this.TransparencyKey = (Color)colorconvert.ConvertFromString("window"); } private void button1_Click(object sender, EventArgs e) { this.Close(); } protected override void OnPaint(PaintEventArgs e) { Graphics g = e.Graphics; Rectangle mainRect = new Rectangle(0, 0, 695, 278); Region mainRegion = new Region(mainRect); e.Graphics.SetClip(mainRegion, CombineMode.Replace); //設(shè)置窗體的外觀形式 Point point1 = new Point(0, 32); Point point2 = new Point(9, 20); Point point3 = new Point(21, 13); Point point4 = new Point(34, 9); // 創(chuàng)建一個(gè)以點(diǎn)為元素的數(shù)組 Point[] curvePoints = { point1, point2, point3, point4 }; // 創(chuàng)建一個(gè)GraphicsPath 對(duì)象并添加一條曲線 GraphicsPath gPath = new GraphicsPath(); gPath.AddCurve(curvePoints, 0, 3, 0.8f); gPath.AddLine(36, 9, 378, 9); point1.X = 378; point1.Y = 9; point2.X = 387; point2.Y = 5; point3.X = 394; point3.Y = 0; Point[] curvePoints2 = { point1, point2, point3 }; gPath.AddCurve(curvePoints2, 0, 2, 0.8f); gPath.AddLine(394, 0, 0, 0); Region rg = new Region(gPath); e.Graphics.ExcludeClip(rg); //可以為任意圖片 string str = Directory.GetCurrentDirectory() + "\\2.png"; Image img = Image.FromFile(str); e.Graphics.DrawImage(img, 0, 0, 695, 278); // 重設(shè)剪切好的區(qū)域 e.Graphics.ResetClip(); } } }
希望本文所述對(duì)大家的C#程序設(shè)計(jì)有所幫助。
欄 目:C#教程
本文標(biāo)題:winform創(chuàng)建不規(guī)則窗體的方法
本文地址:http://mengdiqiu.com.cn/a1/C_jiaocheng/6999.html
您可能感興趣的文章
- 01-10WinForm限制窗體不能移到屏幕外的方法
- 01-10WinForm繪制圓角的方法
- 01-10WinForm實(shí)現(xiàn)仿視頻 器左下角滾動(dòng)新聞效果的方法
- 01-10C#實(shí)現(xiàn)Winform中打開網(wǎng)頁頁面的方法
- 01-10winform實(shí)現(xiàn)創(chuàng)建最前端窗體的方法
- 01-10WinForm實(shí)現(xiàn)自定義右下角提示效果的方法
- 01-10.net2.0+ Winform項(xiàng)目實(shí)現(xiàn)彈出容器層
- 01-10winform 實(shí)現(xiàn)控制輸入法
- 01-10C#動(dòng)態(tài)創(chuàng)建button的方法
- 01-10WinForm實(shí)現(xiàn)程序一段時(shí)間不運(yùn)行自動(dòng)關(guān)閉的方法


閱讀排行
本欄相關(guān)
- 01-10C#通過反射獲取當(dāng)前工程中所有窗體并
- 01-10關(guān)于ASP網(wǎng)頁無法打開的解決方案
- 01-10WinForm限制窗體不能移到屏幕外的方法
- 01-10WinForm繪制圓角的方法
- 01-10C#實(shí)現(xiàn)txt定位指定行完整實(shí)例
- 01-10WinForm實(shí)現(xiàn)仿視頻 器左下角滾動(dòng)新
- 01-10C#停止線程的方法
- 01-10C#實(shí)現(xiàn)清空回收站的方法
- 01-10C#通過重寫Panel改變邊框顏色與寬度的
- 01-10C#實(shí)現(xiàn)讀取注冊(cè)表監(jiān)控當(dāng)前操作系統(tǒng)已
隨機(jī)閱讀
- 01-10C#中split用法實(shí)例總結(jié)
- 08-05dedecms(織夢(mèng))副欄目數(shù)量限制代碼修改
- 01-10使用C語言求解撲克牌的順子及n個(gè)骰子
- 01-10SublimeText編譯C開發(fā)環(huán)境設(shè)置
- 08-05DEDE織夢(mèng)data目錄下的sessions文件夾有什
- 01-11ajax實(shí)現(xiàn)頁面的局部加載
- 04-02jquery與jsp,用jquery
- 01-11Mac OSX 打開原生自帶讀寫NTFS功能(圖文
- 01-10delphi制作wav文件的方法
- 08-05織夢(mèng)dedecms什么時(shí)候用欄目交叉功能?