public static int RoundRect(Graphics e, Pen pen, SolidBrush brush, int X1, int Y1, int X2, int Y2, int X3, int Y3)
{
IntPtr hpen,old_pen;
IntPtr hbrush, old_brush; if(pen!=null)
{
hpen = CreatePen((DashStyle.Solid == pen.DashStyle) ? 0 : 1,
(int)pen.Width, SetRGB(pen.Color.R, pen.Color.G, pen.Color.B)); //创建GDI画笔
}
else
{
hpen = GetStockObject(8); //空画笔
} if (brush!= null)
{
hbrush = CreateSolidBrush(SetRGB(brush.Color.R, brush.Color.G, brush.Color.B)); //brush.Color.ToArgb());
}
else
{
hbrush = GetStockObject(5);
} //pen.Dispose();
//brush.Dispose(); IntPtr hdc = e.GetHdc();
//---------------------
old_brush=SelectObject(hdc, hbrush);
old_pen=SelectObject(hdc, hpen);
int intRet=RoundRect(hdc, X1, Y1, X2,Y2, X3, Y3); SelectObject(hdc, old_brush);
SelectObject(hdc, old_pen);
DeleteObject(hbrush);
DeleteObject(hpen);
//---------------------
e.ReleaseHdc(hdc);
return intRet;
}
|