单文档画网格:
其实就是画线的操作。
CPen mypen,*pCpen;
mypen.CreatePen(0,0,RGB(0,0,255));
pCpen=pDC->SelectObject (&mypen);
for(int j=0;j<cy;j+=cy/10)
{ pDC->MoveTo(0,j);
pDC->LineTo(cx,j);
}
for(int i=0;i<cx;i+=cx/10)
{ pDC->MoveTo(i,0);
pDC->LineTo(i,cy);
}
pDC->SelectObject (pCpen);
mypen.DeleteObject ();
上面画笔可有可无,若无,则有系统默认的画笔。
画笔的选入选出设备环境,selectobject函数,最后还要删除
cx,cy WM_SIZE响应函数里面赋值
void CDrawlineView::OnSize(UINT nType, int cx, int cy)
{
CView::OnSize(nType, cx, cy);
// TODO: Add your message handler code here
this->cx=cx;
this->cy=cy;
}