20041206:
when should NOT we call the base class's corresponding function?
void CDropDownBotton::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
// TODO: Add your message handler code here and/or call default
if(nChar == VK_RETURN || nChar == VK_ESCAPE)
{
if (m_pOrigParent->IsDropDownDialogDown() )
m_pOrigParent->OnDropdownButton();
}
//CButton::OnKeyDown(nChar, nRepCnt, nFlags);
}
in the code snippet above, the base class's corresponding function CButton::OnKeyDown(nChar, nRepCnt, nFlags); is comment out.
The reason is that the CButton has already been destroyed before we call CButton::OnKeyDown.
Another way to fix this kind of bug is to call CWnd::PostMeassage() instead of calling method to destroy CButton.