//GDI+绘制
Graphics graphics(pDC->m_hDC);
//graphics.SetSmoothingMode(SmoothingModeHighQuality);
//graphics.ScaleTransform(m_Scale, m_Scale);
CRect rect;
GetClientRect(&rect);
ClientToDoc(rect);
//中心线
Pen pen(Color(180,180,180), 1);
pen.SetDashStyle(DashStyleCustom);
REAL dashVals[4] = {4.0f, 2.0f};
pen.SetDashPattern(dashVals, 2);
graphics.DrawLine(&pen, rect.left, 0, rect.right, 0);
graphics.DrawLine(&pen, 0, rect.bottom, 0, rect.top);
if (m_Scale >=32 )
{
return;
}
int nTick = 20/m_Scale;
for (int i=0; i<rect.right; i+=10*nTick*m_Scale)
{
graphics.DrawLine(&pen, i, rect.bottom, i, rect.top);
}
for (int i=0; i>rect.left; i-=10*nTick*m_Scale)
{
graphics.DrawLine(&pen, i, rect.bottom, i, rect.top);
}
for (int j=0; j<rect.top; j+=10*nTick*m_Scale)
{
graphics.DrawLine(&pen, rect.left, j, rect.right, j);
}
for (int j=0; j>rect.bottom; j-=10*nTick*m_Scale)
{
graphics.DrawLine(&pen, rect.left, j, rect.right, j);
}
graphics.ReleaseHDC(pDC->m_hDC);
Grid绘制(gdi+)
最新推荐文章于 2021-11-04 13:31:42 发布