15,980
社区成员
发帖
与我相关
我的任务
分享
void DrawCoordinate(CDC* pDC, CRect rectCoord)
{
CString strCoord;
CRect rectTemp;
int i, nSection, nOffset;
CBrush brushFrame;
CSize szText;
brushFrame.CreateSolidBrush(m_clrFrame);
pDC->FillSolidRect(rectCoord, m_clrCoordBkg);
nOffset = 2;
for(i=0; i<=m_nDivisionX; i++)
{
strCoord.Format("%d", m_nRangX*i/m_nDivisionX);
nSection = rectCoord.Width()*i/m_nDivisionX;
szText = pDC->GetTextExtent(strCoord, strCoord.GetLength());
rectTemp.SetRect(rectCoord.left+nSection-szText.cx/2, rectCoord.bottom+nOffset, rectCoord.left+nSection+szText.cx/2, rectCoord.bottom+szText.cy+nOffset);
pDC->MoveTo(rectCoord.left+nSection, rectCoord.top);
pDC->LineTo(rectCoord.left+nSection, rectCoord.bottom);
pDC->DrawText(strCoord, strCoord.GetLength(), rectTemp, DT_CENTER);
}
nOffset = 2;
for(i=0; i<=m_nDivisionY; i++)
{
strCoord.Format("%d", m_nRangY*i/m_nDivisionY);
nSection = rectCoord.Height()*i/m_nDivisionY;
szText = pDC->GetTextExtent(strCoord, strCoord.GetLength());
rectTemp.SetRect(rectCoord.left-szText.cx-nOffset, rectCoord.bottom-nSection-szText.cy/2, rectCoord.left-nOffset, rectCoord.bottom-nSection+szText.cy/2);
pDC->MoveTo(rectCoord.left, rectCoord.top+nSection);
pDC->LineTo(rectCoord.right+1, rectCoord.top+nSection);
pDC->DrawText(strCoord, strCoord.GetLength(), rectTemp, DT_RIGHT);
}
nOffset = 4;
if(!m_bIsShowGrid)
{
rectTemp.SetRect(rectCoord.left+nOffset, rectCoord.top+1, rectCoord.right, rectCoord.bottom-nOffset);
pDC->FillSolidRect(rectTemp, m_clrCoordBkg);
}
}