关于OnDraw()函数的两个问题,请高手指点!

smlboy2018 2005-10-03 10:17:28
以下是设置视图背景颜色的代码:

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.能不能具体的说一下是从什么样子的设备坐标转换到什么样子的逻辑坐标?为什么要转换坐标?

谢谢!
...全文
214 1 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
pomelowu 2005-10-03
  • 打赏
  • 举报
回复
1、 From MSDN
A CRect object can be passed as a function parameter wherever a RECT structure, LPCRECT, or LPRECT can be passed.

2、Search MSDN for "About Coordinate Spaces and Transformations"

15,980

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧