marcus78
asked on
CListCtrl and Unicode(?) Problem
This little bug's got me stumped. I've got a listctrl that I'm dynamically creating in a formview. It is a report style listctrl, which allows the editing of the items.
I'm handling the EndLabelEdit message with the message maps, in the formview:
ON_NOTIFY(LVN_ENDLABELEDIT A,IDC_REPO SITORY, OnEndlabeleditRepository)
ON_NOTIFY(LVN_ENDLABELEDIT W,IDC_REPO SITORY, OnEndlabeleditRepository)
I ended up using these, as a solution to a previous question I asked, where handling LVN_ENDLABELEDIT was not enough to catch the message.
Up to this point, things work fine, and I can handle and validate the edited text. The problem is here:
void CMyView::OnEndlabeleditRep ository(NM HDR* pNMHDR, LRESULT* pResult)
{
CMyView::OnEndlabeleditRep ository(pN MHDR, pResult);
LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
CString strText = pDispInfo->item.pszText;
//do something with the text...
*pResult = TRUE;
}
If I was to enter "Test" then
pDispInfo->item.pszText = T\0e\0s\0t\0
so strText ends up equalling "T"
I think this is a UNICODE issue, and I don't currently have the preprocessor _UNICODE defined. But it's my understanding that a CString should take this and convert it correctly, right?
This works correctly on Win98, and I get this problem on WinNT.
Any ideas on how to remedy this?
Thanks,
Marcus
I'm handling the EndLabelEdit message with the message maps, in the formview:
ON_NOTIFY(LVN_ENDLABELEDIT
ON_NOTIFY(LVN_ENDLABELEDIT
I ended up using these, as a solution to a previous question I asked, where handling LVN_ENDLABELEDIT was not enough to catch the message.
Up to this point, things work fine, and I can handle and validate the edited text. The problem is here:
void CMyView::OnEndlabeleditRep
{
CMyView::OnEndlabeleditRep
LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
CString strText = pDispInfo->item.pszText;
//do something with the text...
*pResult = TRUE;
}
If I was to enter "Test" then
pDispInfo->item.pszText = T\0e\0s\0t\0
so strText ends up equalling "T"
I think this is a UNICODE issue, and I don't currently have the preprocessor _UNICODE defined. But it's my understanding that a CString should take this and convert it correctly, right?
This works correctly on Win98, and I get this problem on WinNT.
Any ideas on how to remedy this?
Thanks,
Marcus
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
also you can separate notifications handler for
LVN_ENDLABELEDITA and
LVN_ENDLABELEDITW
LVN_ENDLABELEDITA and
LVN_ENDLABELEDITW
ASKER
Migel,
This is what I'm looking for. Thanks!
Marcus
This is what I'm looking for. Thanks!
Marcus
I guess the solution is something around
CString str;
if (::IsWindowUnicode(lisctrl
// migel's code here
}
else
str = pDispInfo->item.pszText;
Peter