用获取路径的方法得到圆形窗体(C#2005)
来源:互联网 发布:arm开发用什么软件 编辑:程序博客网 时间:2024/05/02 00:59
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Runtime.InteropServices;using System.Windows.Forms;namespace Example007_用获取路径的方法得到圆形窗体{ public partial class Form1 : Form { [DllImport("gdi32")] private static extern IntPtr BeginPath(IntPtr hdc); [DllImport("gdi32")] private static extern int SetBkMode(IntPtr hdc, int nBkMode); const int TRANSPARENT = 1; [DllImport("gdi32")] private static extern IntPtr EndPath(IntPtr hdc); [DllImport("gdi32")] private static extern IntPtr PathToRegion(IntPtr hdc); [DllImport("gdi32")] private static extern int Ellipse(IntPtr hdc, int X1, int Y1, int X2, int Y2); [DllImport("user32")] private static extern IntPtr SetWindowRgn(IntPtr hWnd, IntPtr hRgn, bool bRedraw); [DllImport("user32")] private static extern IntPtr GetDC(IntPtr hWnd); public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { IntPtr dc; IntPtr region; dc = GetDC(this.Handle);//得到窗体的绘图操作句柄 BeginPath(dc);//记录路径信息 SetBkMode(dc, TRANSPARENT);//设置为透明模式 Ellipse(dc, 20, 20, 220, 220); EndPath(dc);//记录路径信息 region = PathToRegion(dc);//映射路径信息为区域信息 SetWindowRgn(this.Handle, region, true);//设置窗体的形状为指定区域 } //解决窗体的移动问题。 //通过PreProcessMessage方法筛选后,所有窗体消息都发送到WndProc方法。 //本实例通过重载该方法取到WM_NCHITTEST消息,默认处理后,通过m.Result = (IntPtr)HTCAPTION语句设置消息处理的返回值为HTCAPTION。 //这样用户在窗体中拖动鼠标时,即可以达到和拖动标题栏相同的效果。 const int WM_NCHITTEST = 0x0084; const int HTCLIENT = 0x0001; const int HTCAPTION = 0x0002; protected override void WndProc(ref Message m) { switch (m.Msg) { case WM_NCHITTEST: base.WndProc(ref m); if (m.Result == (IntPtr)HTCLIENT) m.Result = (IntPtr)HTCAPTION; break; default: base.WndProc(ref m); break; } } }}
- 用获取路径的方法得到圆形窗体(C#2005)
- Control Study -> 用获取路径方法得到圆形窗体(如将: PictureBox变成圆形)
- Control Study -> 用获取路径方法得到圆形窗体(如将: PictureBox变成圆形)
- Control Study -> 用获取路径方法得到圆形窗体(如将: PictureBox变成圆形)
- 【C#】[窗体]圆形窗体(获取路径)
- iOS 得到圆形头像的方法
- C#获取路径方法
- C#获取路径方法
- C#获取程序当前路径的方法
- C#获取项目程序路径的方法
- C#中获取路径的多种方法
- C#获取当前路径的方法!
- C#获取当前路径的方法集合
- C#获取项目程序路径的方法
- C#获取项目程序路径的方法
- C#获取当前路径的方法集合
- C#获取项目程序路径的方法
- C#获取当前路径的方法集合
- Windows 64位计算的世界
- .Net 中通用的FormatString格式符整理
- sqlserver2000升级到2005总结
- Net程序如何防止被注入(整站通用)
- 选对池塘钓大鱼
- 用获取路径的方法得到圆形窗体(C#2005)
- 把datagridview的数据输出为Excel,Word的二种应用
- 创建可移植的64位代码
- ER-关系映射方法
- 域(C#)
- 去除64位平台的内存错误
- 若不会推销,如何获得工作机会?
- 三列等高CSS布局的一个实例
- vmware下面安装Ubuntu使用鼠标滚动的方法