CRect::operator LPRECT
来源:互联网 发布:浙江省数据库三级 编辑:程序博客网 时间:2024/06/06 02:07
When you use this function, you don't need the address-of ( &) operator. This operator will be automatically used when you pass a CRect object to a function that expects an LPRECT.
Example:
BOOL CMyDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// CWnd::GetWindowRect() takes a LPRECT, but we can
// simply pass our CRect object because of the LPRECT
// cast operator in the CRect class.
CRect rect; GetWindowRect(rect);
// Similarly, CWnd::MoveWindow() takes a LPCRECT but
// the LPCRECT cast operator is used implicitly:
MoveWindow(rect, FALSE);
return TRUE;
}
什么意思呢?
MFC定义了LPRECT类型转换,那么在使用要求LPRECT类型指针的地方可以直接使用CRect对象。
例如:
void GetClientRect( LPRECT lpRect ) const;
BOOL Rectangle( LPCRECT lpRect );
BOOL Ellipse( LPCRECT lpRect );
这些函数中可以写为如下形式
CRect rect;
GetClientRect(&rect);
pDC->Rectangle(&rect);
pDC->Ellipse(&rect);
也可以写为去掉&的形式
CRect rect;
GetClientRect(rect);
pDC->Rectangle(rect);
pDC->Ellipse(rect);
实例:
void CMy123View::OnDraw(CDC* pDC)
{
CMy123Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
if (!pDoc)return;
// TODO: add draw code for native data hereCRect rect;
GetClientRect(rect);
pDC->Rectangle(rect);
pDC->Ellipse(rect);
}
效果图
Example:
BOOL CMyDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// CWnd::GetWindowRect() takes a LPRECT, but we can
// simply pass our CRect object because of the LPRECT
// cast operator in the CRect class.
CRect rect; GetWindowRect(rect);
// Similarly, CWnd::MoveWindow() takes a LPCRECT but
// the LPCRECT cast operator is used implicitly:
MoveWindow(rect, FALSE);
return TRUE;
}
什么意思呢?
MFC定义了LPRECT类型转换,那么在使用要求LPRECT类型指针的地方可以直接使用CRect对象。
例如:
void GetClientRect( LPRECT lpRect ) const;
BOOL Rectangle( LPCRECT lpRect );
BOOL Ellipse( LPCRECT lpRect );
这些函数中可以写为如下形式
CRect rect;
GetClientRect(&rect);
pDC->Rectangle(&rect);
pDC->Ellipse(&rect);
也可以写为去掉&的形式
CRect rect;
GetClientRect(rect);
pDC->Rectangle(rect);
pDC->Ellipse(rect);
实例:
void CMy123View::OnDraw(CDC* pDC)
{
CMy123Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
if (!pDoc)return;
// TODO: add draw code for native data hereCRect rect;
GetClientRect(rect);
pDC->Rectangle(rect);
pDC->Ellipse(rect);
}
效果图
0 0
- CRect::operator LPRECT
- CRect
- CRECT
- CRect
- CRect
- CRect
- CRect
- CRect
- BOOL GetClientRect(HWND hWnd,LPRECT lpRect);
- RECT与LPRECT
- CRect类
- CRect操作
- CRect结构
- CRect capPreview()
- CRect类
- CRect::DeflateRect()
- CRect类
- operator->*
- 钻石恒久远,一颗永相传
- 从线框模型到表面模型绘制技术的联想
- 我的图形学网站,备忘
- 扩大矩形函数和缩小矩形函数的用法
- LeetCode - Swap Nodes in Pairs - Frequent
- CRect::operator LPRECT
- Win7操作系统下安装VC++6.0、MSDN并使用MFC绘图
- 孔令德的计算机图形学课程实验
- Android中的Shape使用总结
- java后端系统架构之jvm远程监控
- iOS开发之多线程编程 (2)
- [COGS902]乐曲主题
- Struts2漏洞分析
- LeetCode - Rotate List