需从CButton派生一个类,并重写OnKillFocus函数,示例如下:
BEGIN_MESSAGE_MAP(CFocusButton, CButton)
ON_WM_KILLFOCUS()
END_MESSAGE_MAP()
// CFocusButton message handlers
void CFocusButton::OnKillFocus(CWnd* pNewWnd)
{
CButton::OnKillFocus(pNewWnd);
// TODO: Add your message handler code here
GetParent()->SendMessage( WM_NOFOCUS );
}