关于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.能不能具体的说一下是从什么样子的设备坐标转换到什么样子的逻辑坐标?为什么要转换坐标?
谢谢!
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.能不能具体的说一下是从什么样子的设备坐标转换到什么样子的逻辑坐标?为什么要转换坐标?
谢谢!
...全文
相关推荐
OnPaint()与OnDraw()的区别
OnPaint()与OnDraw()的区别
ondraw不执行,请大神帮忙
ondraw不执行,请大神帮忙
OnDraw与OnPaint有什么区别
详细介绍OnDraw与OnPaint有什么区别
Android 中View.onDraw(Canvas canvas)的使用方法
主要介绍了Android 中View.onDraw(Canvas canvas)的使用方法的相关资料,希望通过本文能帮助到大家,需要的朋友可以参考下
Android 通过onDraw实现在View中绘图操作的示例
以下是对Android通过onDraw实现在View中绘图操作的示例代码进行了详细的分析介绍,需要的朋友可以过来参考下


界面
