LVN_GETDISPINFO Using SendMessage
-
Im trying to get the item details of a CListCtrl m_lst1. Using the foloowing code... only that im not getting any result any suggestions -------------------------//-- char szLabel[256]; NMLVDISPINFO NMLVDispInfo; ZeroMemory(&NMLVDispInfo.item, sizeof(LVITEM)); NMLVDispInfo.hdr.code = LVN_GETDISPINFO; NMLVDispInfo.hdr.hwndFrom = AfxGetMainWnd()->m_hWnd; NMLVDispInfo.hdr.idFrom = AfxGetMainWnd()->GetDlgCtrlID(); NMLVDispInfo.item.iItem = 1; NMLVDispInfo.item.mask = LVIF_DI_SETITEM| LVIF_TEXT; NMLVDispInfo.item.pszText = szLabel; NMLVDispInfo.item.cchTextMax = 255; m_lst1.SendMessage(WM_NOTIFY, (WPARAM)NMLVDispInfo.hdr.hwndFrom, (LPARAM)(LPNMHDR) &NMLVDispInfo); -------------------------//--
-
Im trying to get the item details of a CListCtrl m_lst1. Using the foloowing code... only that im not getting any result any suggestions -------------------------//-- char szLabel[256]; NMLVDISPINFO NMLVDispInfo; ZeroMemory(&NMLVDispInfo.item, sizeof(LVITEM)); NMLVDispInfo.hdr.code = LVN_GETDISPINFO; NMLVDispInfo.hdr.hwndFrom = AfxGetMainWnd()->m_hWnd; NMLVDispInfo.hdr.idFrom = AfxGetMainWnd()->GetDlgCtrlID(); NMLVDispInfo.item.iItem = 1; NMLVDispInfo.item.mask = LVIF_DI_SETITEM| LVIF_TEXT; NMLVDispInfo.item.pszText = szLabel; NMLVDispInfo.item.cchTextMax = 255; m_lst1.SendMessage(WM_NOTIFY, (WPARAM)NMLVDispInfo.hdr.hwndFrom, (LPARAM)(LPNMHDR) &NMLVDispInfo); -------------------------//--
fordge wrote: NMLVDISPINFO NMLVDispInfo; ZeroMemory(&NMLVDispInfo.item, sizeof(LVITEM)); Not that I'm providing any help with your problem at hand, but since you are using C++ you should be aware you can do:
NMLVDISPINFO NMLVDispInfo = { 0 };
To zero-initialize the struct. That your code fills the struct with zeros based on the size of a completely unrelated struct (the boldface parts) also displays this technique could help create less buggy programs.