MFC 派生类的为什么还要调用基类的函数?? 5
(1):BOOLCXJWDigitClock::OnEraseBkgnd(CDC*pDC){//TODO:Addyourmessagehandlercodehereand...
(1):
BOOL CXJWDigitClock::OnEraseBkgnd(CDC* pDC)
{
// TODO: Add your message handler code here and/or call default
CBrush brush;
brush.CreateSolidBrush( ::GetSysColor(COLOR_WINDOWTEXT) );
CBrush* pOldBrush = pDC->SelectObject(&brush);
CRect rectClient;
GetClientRect(&rectClient);
pDC->PatBlt(0, 0, rectClient.Width(), rectClient.Height(), PATCOPY);
pDC->SelectObject(pOldBrush);
//这里
return CStatic::OnEraseBkgnd(pDC);
}
(2)
void CSy2View::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
// TODO: Add your message handler code here and/or call default
switch(nChar)
{
case VK_LEFT; //光标左移
x--;
break;
case VK_RIGHT; //光标右移
x++;
break;
case VK_UP; //光标上移
y--;
break;
case VK_DOWN; //光标下移
y++;
break;
}
Invalidate(); //更新视图
CView::OnKeyDown(nChar, nRepCnt, nFlags);
}
在最后调用了基类CView的同名成员函数OnKeyDown,这个有啥作用,做啥的 展开
BOOL CXJWDigitClock::OnEraseBkgnd(CDC* pDC)
{
// TODO: Add your message handler code here and/or call default
CBrush brush;
brush.CreateSolidBrush( ::GetSysColor(COLOR_WINDOWTEXT) );
CBrush* pOldBrush = pDC->SelectObject(&brush);
CRect rectClient;
GetClientRect(&rectClient);
pDC->PatBlt(0, 0, rectClient.Width(), rectClient.Height(), PATCOPY);
pDC->SelectObject(pOldBrush);
//这里
return CStatic::OnEraseBkgnd(pDC);
}
(2)
void CSy2View::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
// TODO: Add your message handler code here and/or call default
switch(nChar)
{
case VK_LEFT; //光标左移
x--;
break;
case VK_RIGHT; //光标右移
x++;
break;
case VK_UP; //光标上移
y--;
break;
case VK_DOWN; //光标下移
y++;
break;
}
Invalidate(); //更新视图
CView::OnKeyDown(nChar, nRepCnt, nFlags);
}
在最后调用了基类CView的同名成员函数OnKeyDown,这个有啥作用,做啥的 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询