Mike Landis wrote: On subclassing, I've been using the Wizard to define classes. Finish the dialog in the resource, Ctrl-W, New class, etc. I think it's sewn together right. If you bring up the Wizard over any of my dialogs, you immediately see the subclass, messages, member functions... Yes, but this only takes care of subclassing the *dialog*. If you want to handle reflected notifications in list control, you'll also have to subclass it. Otherewise, nobody will scan its message map - it'll be plain Win32 control with no MFC window procedure behind. I guess haven't used ClassWizard's 'Member Vars' tab to associate CYourListCtrl with any control ID. How does DoDataExchange looks like in your dialog? It should have something like DDX_Control(pDX, IDC_LIST1, m_lst1); Can you post example code or suggest a URL where strncpy is used to solve the longevity problem? strncpy, or rather wcsncpy - because WinCE is Unicode only - skips over longevity. In your approach, you're trying to keep string data for some time, and you're just setting item.pszText to point inside your pool. But when your LVN_GETDISPINFO handler is called, list control itself has initialized pszText. It points to its internal buffer, managed by Windows. You can create the string you need on the fly, and instead of stuffing it into pool copy it into this buffer using wcsncpy. Here how it looks in my test app running just fine on hp1910: void CTestListCtrl::OnGetdispinfo(NMHDR* pNMHDR, LRESULT* pResult) { LV_DISPINFO* pdi = (LV_DISPINFO*)pNMHDR; if (LVIF_TEXT & pdi->item.mask) { CString strItem; strItem.Format(_T("Item %d - %d"), pdi->item.iItem, pdi->item.iSubItem); wcsncpy(pdi->item.pszText, strItem, pdi->item.cchTextMax); } *pResult = 0; }
You don't care about the lifetime of strItem, because it is copied before leaving OnGetdispinfo. I'm sending the source of my test app to your email account. It's 12 kb zip file; solves all problems you've reported (handles NM_CUSTOMDRAW/LVN_GETDISPINFO in list control class and changes colors of list items). Tomasz Sowinski -- http://www.shooltz.com
Alika masiaka!