点击Escape与Enter在CListCtrl中触发LVN_ENDLABELEDIT

时间:2010-08-02 16:15:33

标签: c++ mfc listbox clistctrl

如果在两种情况下编辑字段为空,我如何区分这两者?
当用户点击逃生时,我认为用户根本不想要新值 输入命中,我假设用户想要编辑项目的空字符串...

1 个答案:

答案 0 :(得分:1)

BEGIN_MESSAGE_MAP(CMyPropertyPage, CPropertyPage)
//{{AFX_MSG_MAP(CMyPropertyPage)
    ON_NOTIFY(LVN_ENDLABELEDIT, IDC_LIST_CONTROL, OnEndLabelEdit)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

void CMyPropertyPage::OnEndLabelEdit(NMHDR* pNMHDR, LRESULT* pResult) 
{
    LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
    if (pDispInfo->item.pszText == NULL)
    {
             //Used clicked escape
     }
     else
     {
            //Data was accepted by user, empty string perhaps?
     }
}