源碼
這個(gè)類的使用方法很簡單,3DBbar中一共有7個(gè)public函數(shù)。分別為:
void SetBarColour(COLORREF cr);
void DrawHorizontal(CDC* pDC, CRect& BarRect); //畫水平bar
void DrawVertical(CDC*pDC,CRect& BarRect); //畫垂直bar
void DrawLeft(CDC*pDC,CRectleftRect); //畫左邊bar
void DrawRight(CDC*pDC,CRectrightRect); //畫右邊bar
void DrawTop(CDC*pDC,CRect&topRect); //畫頂邊bar
void DrawBottom(CDC*pDC,CRect&bottomRect); //畫底邊bar
從以上我們也可以看到,其實(shí)我們在用的時(shí)候一般用的是SetBarColour(COLORREF cr)、 DrawLeft、DrawRight、DrawTop和DrawBottom這5個(gè)函數(shù),用法也很簡單。如:我們在一個(gè)自定義的Static CDigiStatic中使用??梢苑譃橐韵聨撞剑?
1、首先把3DBar.h 和3DBar.cpp 加入到你的工程中。
2、在你使用的類中加入頭文件,#include "3dbar.h"
3、申明一個(gè)C3DBar對象。C3DBar Bar;
4、在類的初始化中調(diào)用Bar的函數(shù):SetBarColour;
5、在你使用的類的OnPaint();函數(shù)中調(diào)用前面介紹的4個(gè)函數(shù)就可以了。
例如: 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);
}