简体   繁体   English

未调用 OnKillFocus

[英]OnKillFocus not being called

I have a CFormView derived class where I want to call a method when focus is lost.我有一个 CFormView 派生类,我想在失去焦点时调用一个方法。

Tried this:试过这个:

MyClass.cpp我的类.cpp

ON_CONTROL_REFLECT(EN_KILLFOCUS, OnKillFocus)

void CMyClass::OnKillFocus()
{
}

MyClass.h我的类.h

afx_msg void OnKillFocus();

But my method is not being called, is there some way to achieve what I want?但是我的方法没有被调用,有什么方法可以实现我想要的吗?

Relevant message and functions are相关的消息和功能是

ON_WM_KILLFOCUS()

and

afx_msg void OnKillFocus(CWnd* pNewWnd);

EN_KILLFOCUS and other EN_XXX notifications are specific to Edit controls. EN_KILLFOCUS和其他EN_XXX通知特定于编辑控件。 For example:例如:

BEGIN_MESSAGE_MAP(CMyDialog, CDialog)
    ON_EN_KILLFOCUS(IDC_EDIT1, OnMyFunction)
END_MESSAGE_MAP()

void OnMyFunction();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM