【求助】为什么这个程序的虚线画不出来?
用MFC建立的 单文档做的是一个图表,Y轴上本来是需要能显示数字及一条条每隔30显示虚线的程序
可是Y轴上不显示,虚线也不显示。。求高手帮忙调试,我是调试不出来了
那一段程序我用红色标示出来了。。。
void CMy0103View::OnDraw(CDC* pDC)
{
CMy0103Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
const int x0 = 40, y0 = 20, x1 = 520, y1 = 380;
const int N = 12, dx = (x1 - x0) / N, h = dx / 4;
const int M = 10, dy = 30;
int a[N] = {172, 33, 36, 143, 224, 34, 234, 34, 56, 45, 180, 232};
CPoint v[4];
CString s;
CBrush br;
CPen pen, *p_pen;
int x, i, y;
#define R rand() % 56 + 200
BYTE r, g, b;
srand((unsigned)time(NULL));
pDC->Rectangle(x0, y0, x1 + h + 40, y1 + 1);
pDC->MoveTo(x0, y1);
pDC->LineTo(x = x1 + 2 * dx, y1);
pDC->MoveTo(x, y1);
pDC->LineTo(x - 12, y1 - 3);
pDC->MoveTo(x, y1);
pDC->LineTo(x - 12, y1 + 3);
pDC->MoveTo(x0, y0);
pDC->LineTo(x0, 0);
pDC->MoveTo(x0, 0);
pDC->LineTo(x0 - 3, 12);
pDC->MoveTo(x0, 0);
pDC->LineTo(x0 + 3, 12);
pen.CreatePen(PS_SOLID, 2, RGB(0, 0, 0));
p_pen = pDC->SelectObject(&pen);
for (i = 0, x = x0; i < N; ++i, x+=dx)
{
br.CreateSolidBrush(RGB(r = R, g = R, b = R));
pDC->SelectObject(&br);
pDC->Rectangle(x, y1 - a[i], x + dx, y1);
v[0].x = x + dx; v[0].y = y1 - a[i];
v[1].x = v[0].x + h; v[1].y = v[0].y - h;
v[2].x = v[1].x - dx; v[2].y = v[1].y;
v[3].x = v[2].x -h; v[3].y = v[2].y + h;
pDC->Polygon(v, 4);
pDC->SelectStockObject(WHITE_BRUSH);
br.DeleteObject();
if (i == N - 1 || a[i] > a[i + 1])
{
br.CreateSolidBrush(RGB(r*0.7, g*0.7, b*0.7));
pDC->SelectObject(&br);
v[2].x = v[1].x; v[2].y = v[1].y + a[i];
v[3].x = x + dx; v[3].y = y1;
pDC->Polygon(v, 4);
pDC->SelectStockObject(WHITE_BRUSH);
br.DeleteObject();
}
}
pDC->SelectObject(p_pen);
pen.DeleteObject();
pen.CreatePen(PS_DOT, 1, RGB(100, 100, 100));
p_pen = pDC->SelectObject(&pen);
pDC->SetROP2(R2_MASKPEN);
for(y = y1, i = 0; y >= y0; ++i, y -=dy);
{
if ((y != y0) && (y != y1))
{
pDC->MoveTo(x0, y);
pDC->LineTo(x1 + h, y);
}
s.Format("%3d", dy * i);
pDC->TextOut(10, y - 8, s);
}
pDC->SelectObject(p_pen);
pen.DeleteObject();
for (i = 0; i < N; ++i)
{
s.Format("%d", a[i]);
pDC->TextOut(x0 + i*dx + (dx-s.GetLength()*8) / 2, y1 + 4, s);
}
// TODO: add draw code for native data here
}