Grid绘制(gdi+)
程序员文章站
2022-03-31 20:08:42
...
//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);
上一篇: PHP中预定义的6种接口解析
下一篇: 有关reset()的文章推荐10篇