关于NFC中SIZE消息响应的问题
来源:百度知道 编辑:UC知道 时间:2024/06/04 17:27:43
随便来个例子,把OnSize消息响应部分贴出来
是MFC
很简单,关键是在OnSize获得变化后的客户区矩形,然后根据这个矩形调整画图参数,然后在画图就可以了。
首先定义一个类的成员变量:
CRect m_rectClient;
OnSize中的代码
void CTestView::OnSize(UINT nType, int cx, int cy)
{
CView::OnSize(nType, cx, cy);
// TODO: Add your message handler code here
GetClientRect(m_rectClient);//获得客户区矩形
}
OnDraw中代码,画一个始终距离边框为30的矩形
void CTestView::OnDraw(CDC* pDC)
{
CTestDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
//画一个始终距离边长为30的矩形
CRect rect;
rect.left = m_rectClient.left+30;
rect.top = m_rectClient.top+30;
rect.right = m_rectClient.right-30;
rect.bottom = m_rectClient.bottom-30;
CBrush brush(RGB(0,0,255));//创建蓝色画刷
pDC->SelectObject(&brush);
pDC->Rectangle(&rect);//画矩形
}
NFC??? 不是MFC???
图形不是以窗口的边界作为像素起点的么?