Wince嵌入式开发时,C#怎么绘制圆角的控件?
想把控件做下美化,可是智能设备中很多方法都没了,不能够实现!!调用WinApi的CreateRoundRectRgn函数,缺出现找不到该函数,无语了!!请问除了用图片来做,还有其他更好的方法没??
我从 opennetcf库里抠了个 opennetcf.drawing出来。
可以绘制圆角了。
opennetcf.drawing 传附件了,
OpenNETCF.Drawing.rar
(116.05 KB)
实例代码:
程序代码:
using System; using System.Drawing; using System.Windows.Forms; using OpenNETCF.Drawing; namespace SmartButton { public partial class UserControl1 : UserControl { public UserControl1() { InitializeComponent(); } /// <summary> /// 控件重绘 /// </summary> /// <param name="e"></param> protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); e.Graphics.Clear(Color.Transparent); IntPtr hdc = e.Graphics.GetHdc(); GraphicsEx gx = GraphicsEx.FromHdc(hdc); PenEx p=new PenEx(Color.Black); gx.DrawRoundRectangle(p, this.ClientRectangle, new Size(10, 10)); } /// <summary> /// 将控件背景设置为透明( System.Drawing.Color.Transparent;) /// 需要重写这个方法,但不用做任何事,防止控件闪烁 /// </summary> /// <param name="e"></param> protected override void OnPaintBackground(PaintEventArgs e) { } } }