关于OnDraw()函数的两个问题,请高手指点!
以下是设置视图背景颜色的代码:
void CTestView::OnDraw(CDC* pDC)
{
CTestDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
CRect rectClient;
CBrush brushBkColor;
GetClientRect(rectClient);
brushBkColor.CreateSolidBrush(RGB(255,0,0));
pDC->DPtoLP(rectClient);
pDC->FillRect(rectClient,&brushBkColor);
…
}
我有两个问题:
1.我在MSDN中查看了GetClientRect()函数的说明是:void GetClientRect( LPRECT lpRect )const
其中的参数lpRect:Points to a RECT structure or a CRect object to receive the client coordinates. 也就是说,lpRect是一个指向RECT结构或者是一个CRect对象的指针,但是上面的GetClientRect(rectClient)参数是CRect rectClient,而rectClient并不是定义成指针的啊!
2.void DPtoLP(LPRECT lpRect) const;的作用是Converts device units into logical units.This parameter is used for the simple case of converting one rectangle from device points to logical points.能不能具体的说一下是从什么样子的设备坐标转换到什么样子的逻辑坐标?为什么要转换坐标?
谢谢!