单文档:利用画刷填充矩形,很简单
CRect rc(10,10,20,200);
CBrush bru;
bru.CreateHatchBrush (HS_BDIAGONAL ,RGB(0,0,255));
pDC->SelectObject (&bru);
pDC->Rectangle (&rc);
pDC->SelectObject (&bru);
bru.DeleteObject ();
这是二维的,下面是三维的
三维的直方图,只是照我们手画圆柱体,在二维的基础上在上面和侧面加了平行四边
CRect rc(50,50,100,200);
CBrush bru;
CPoint r[4];
bru.CreateHatchBrush (HS_BDIAGONAL ,RGB(0,0,255));
pDC->SelectObject (&bru);
pDC->Rectangle(&rc);
//顶部四边形
r[0].x=50;r[0].y=50;
r[1].x =100;r[1].y=0;
r[2].x=150;r[2].y=0;
r[3].x=100;r[3].y=50;
pDC->Polygon (r,4);
r[0].x=100;r[0].y=200;
r[1].x =150;r[1].y=150;
r[2].x=150;r[2].y=0;
r[3].x=100;r[3].y=50;
pDC->Polygon (r,4);
pDC->SelectObject (&bru);
bru.DeleteObject ();