Search code examples
c++mfclistboxclistctrl

Hitting Escape versus Enter triggering LVN_ENDLABELEDIT in CListCtrl


how can I differentiate between the two, when the edit field is empty in both cases?
when the user hits escape, I assume user doesn't want the new value at all, when
enter is hit, I assume the user wants an empty string for the edited item...


Solution

  • 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?
         }
    }