分类: C/C++
2008-08-01 16:54:00
void SetBarColour(COLORREF cr);
void DrawHorizontal(CDC* pDC, CRect& BarRect); //画水平bar
void DrawVertical(CDC*pDC,CRect& BarRect); //画垂直bar
void DrawLeft(CDC*pDC,CRect&leftRect); //画左边bar
void DrawRight(CDC*pDC,CRect&rightRect); //画右边bar
void DrawTop(CDC*pDC,CRect&topRect); //画顶边bar
void DrawBottom(CDC*pDC,CRect&bottomRect); //画底边bar
从以上我们也可以看到,其实我们在用的时候一般用的是SetBarColour(COLORREF
cr)、 DrawLeft、DrawRight、DrawTop和DrawBottom这5个函数,用法也很简单。如:我们在一个自定义的Static CDigiStatic中使用。可以分为以下几步:
void CDigiStatic::OnPaint()
{
CRect dlgrect;
GetClientRect(&dlgrect);
CRect rectleft(0,0,dlgrect.Width()/30,dlgrect.bottom),\
rectright(dlgrect.right-dlgrect.Width()/30,0,dlgrect.right,dlgrect.bottom),\
recttop(0,0,dlgrect.right,dlgrect.Width()/30),\
rectbottom(0,dlgrect.bottom-dlgrect.Width()/30,dlgrect.right,dlgrect.bottom);
CPaintDC dc(this); // device context for painting
Bar.DrawLeft(&dc,rectleft);
Bar.DrawTop(&dc,recttop);
Bar.DrawBottom(&dc,rectbottom);
Bar.DrawRight(&dc,rectright);
}
下载本文示例代码