
c# winForm关于重绘控件的形状
1个回答
展开全部
把form的FormBorderStyle设置为None,最小化和关闭按钮拖,都重画吧,详细看下gdi+,类似下面的,改改就ok了.
public void Render(Graphics graphics)
{
Pen pen;
Brush brush;
int x, y;
int textWidth, textHeight;
brush = new SolidBrush(IsSelectedValue ?
CaptionColor : Color.White);
pen = new Pen(Color.Black);
graphics.FillEllipse(brush, PositionLeftX, PositionTopY,
SizeWidth, SizeHeight);
graphics.DrawEllipse(pen, PositionLeftX, PositionTopY,
SizeWidth, SizeHeight);
textWidth = (int)graphics.MeasureString(CaptionName,
CaptionFont).Width;
textHeight = (int)graphics.MeasureString(CaptionName,
CaptionFont).Height;
x = PositionLeftX + (SizeWidth - textWidth) / 2;
y = PositionTopY + (SizeHeight - textHeight) / 2;
graphics.DrawString(CaptionName, CaptionFont,
new SolidBrush(IsSelectedValue ? Color.White : CaptionColor),
x, y);
brush.Dispose();
}
public void Render(Graphics graphics)
{
Pen pen;
Brush brush;
int x, y;
int textWidth, textHeight;
brush = new SolidBrush(IsSelectedValue ?
CaptionColor : Color.White);
pen = new Pen(Color.Black);
graphics.FillEllipse(brush, PositionLeftX, PositionTopY,
SizeWidth, SizeHeight);
graphics.DrawEllipse(pen, PositionLeftX, PositionTopY,
SizeWidth, SizeHeight);
textWidth = (int)graphics.MeasureString(CaptionName,
CaptionFont).Width;
textHeight = (int)graphics.MeasureString(CaptionName,
CaptionFont).Height;
x = PositionLeftX + (SizeWidth - textWidth) / 2;
y = PositionTopY + (SizeHeight - textHeight) / 2;
graphics.DrawString(CaptionName, CaptionFont,
new SolidBrush(IsSelectedValue ? Color.White : CaptionColor),
x, y);
brush.Dispose();
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询