edit CListCtrl

HI,everybody:
I have a simple program regarding listview.
I have already set the style of my listview to LVS_EDITLABELS and I also add message handler like this:

void CMyListCtrl::OnEndLabelEdit(NMHDR* pNMHDR, LRESULT* pResult)
{
        *pResult = TRUE;
}


But after I edit the first column lable,the change aint be saved,it retains  as original.

Why?
I debug and I find the above message handler never be reached .
Please help me,it's very urgent.
Thanks


SFSAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Vinayak KumbarSr Program ManagerCommented:
Hi,

I dont think this question is so easy.
R u trying to edit the column headers? or the items?.

Pls specify.

VinExpert
0
SFSAuthor Commented:
I only try to edit it the the first conlumn of items, I just do experiment from codeguru.
Now I can let the edit box pop up to edit but the problem is after I finish it,the text in the first column back to original text.
I add end... message handler in my clistctrl but it never be reached.
Thanx alot, VinExpert
SFS
0
Vinayak KumbarSr Program ManagerCommented:
Hi,

Fine,

U may be having Ur own class for the CEdit then map the OnKillFocus() to it and add the following code
void CMyEdit::OnKillFocus(CWnd* pNewWnd)
{
      CEdit::OnKillFocus(pNewWnd);

      //Fill the display info and send the end editing of label message to parent      
      CString l_strText;
      GetWindowText(l_strText);

      LV_DISPINFO dispinfo;
      dispinfo.hdr.hwndFrom = GetParent()->m_hWnd;
      dispinfo.hdr.idFrom = GetDlgCtrlID();
      dispinfo.hdr.code = LVN_ENDLABELEDIT;

      dispinfo.item.mask = LVIF_TEXT;
      dispinfo.item.iItem = m_iItem;
      dispinfo.item.iSubItem = m_iSubItem;
      dispinfo.item.pszText = LPTSTR((LPCTSTR)l_strText);
      dispinfo.item.cchTextMax = l_strText.GetLength();

      GetParent()->GetParent()->SendMessage( WM_NOTIFY, GetParent()->GetDlgCtrlID(), (LPARAM)&dispinfo );

      PostMessage( WM_CLOSE );
}

Then in the End... message mapped function put the following code
if(pDispInfo->item.pszText != NULL)
{
SetItemText(pDispInfo->item.iItem, pDispInfo->item.iSubItem, pDispInfo->item.pszText);
}

I have the sample workspace. Is u give me ur emailID, I will send it to U.

Hope this helps.
VinExpert
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

Vinayak KumbarSr Program ManagerCommented:
Hi,

Sorry for the spell mistakes. Give me Ur email ID, I will send the sample workspace to u.

Cheers,
VinExpert
0
V_BapatCommented:
No need to use cannon to kill an ant. Try this out:

void CMyListCtrl::OnEndLabelEdit(NMHDR* pNMHDR, LRESULT* pResult)
{
      LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;

      LVITEM lvi;
      m_listctrl.GetItem(&lvi);
      lvi.pszText = pDispInfo->item.pszText;
      m_listctrl.SetItem(&lvi);

      *pResult = TRUE;
}
0
V_BapatCommented:
If you want to edit subitems, then think about creating an edit control.
0
SFSAuthor Commented:
NO,my dear friends.YOu misunderstand me totally!!
Maybe I didnt make it clear,as I said ,I dont wanna edit the subitem but the first column item,SO it'n unnecessary for me to create an edit box and it should be very easy.
Now my problem is I add the style in resource workplace and I add message handler for endedititem in Cmylistctrl but it seems the handler never be reached,if I add the handler in the dialoge,it be reached,why?
THe other problem is the change never be retained.HOw to?
Thanks
To vinexpert:
thank you and if you 'd like to mail it to me for info,please send the code to
geeboy@163.net
Thanx.
0
Vinayak KumbarSr Program ManagerCommented:
Hi,

I have sent u the sample workspace.

Try it out.

VinExpert
0
V_BapatCommented:
>Now my problem is I add the style in resource workplace and I add message handler for endedititem in Cmylistctrl but it seems the handler never be reached,if I add the handler in the dialoge,it be reached,why?

It should reach in your derived list control also.

>The other problem is the change never be retained.HOw to?
To retain the changes, *you* have to make changes using either SetItem or SetItemText. You can make changes as I suggested in my last post. Try it out.

Vicky
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.