How to identify image in ListCtrl
-
Hi All, I used customized ListCtrl in my application. I derived class from CListCtrl clas. I add JPEG images in ListCtrl now i want to check that which JPEG image is selected by the user. I use following code but it does not return me image path or image name. void CSelectBusCategory::OnSelectItemFromList(NMHDR* pNMHDR, LRESULT* pResult) { int nItem,nSubItem,nLen; NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR; *pResult = 0; // CString strJPEGFileName = mWebPagePrvListCtrl.GetItemText(pNMListView->iItem,pNMListView->iSubItem); // MessageBox(strJPEGFileName); } Is there any other code to retrive path of JPEG image Thanks in Advance Atul
-
Hi All, I used customized ListCtrl in my application. I derived class from CListCtrl clas. I add JPEG images in ListCtrl now i want to check that which JPEG image is selected by the user. I use following code but it does not return me image path or image name. void CSelectBusCategory::OnSelectItemFromList(NMHDR* pNMHDR, LRESULT* pResult) { int nItem,nSubItem,nLen; NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR; *pResult = 0; // CString strJPEGFileName = mWebPagePrvListCtrl.GetItemText(pNMListView->iItem,pNMListView->iSubItem); // MessageBox(strJPEGFileName); } Is there any other code to retrive path of JPEG image Thanks in Advance Atul
Atulmahajan wrote:
I use following code but it does not return me image path or image name.
Store that information by calling
SetItemData()
for each image added to the control. Then when you are responding to an image selection, callGetItemData()
.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
Atulmahajan wrote:
I use following code but it does not return me image path or image name.
Store that information by calling
SetItemData()
for each image added to the control. Then when you are responding to an image selection, callGetItemData()
.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
Thanks for reply, If I use SetItemData() function it takes 2 parameter 1)index 2) 32 bit DWORD value. I can pass index but what value should i pass to DWORD parameter. Plz reply to this question. Thanks in Advance atul
Atulmahajan wrote:
what value should i pass to DWORD parameter.
Remember that pointers to memory address are just 32-bit numbers.
char *pszPath = new char[29];
strcpy(pszPath, "c:\\windows\\system32\\calc.exe");
int nIndex = mWebPagePrvListCtrl.InsertItem(...);
mWebPagePrvListCtrl.SetItemData(nIndex, (DWORD) pszPath);
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
Thanks for reply, If I use SetItemData() function it takes 2 parameter 1)index 2) 32 bit DWORD value. I can pass index but what value should i pass to DWORD parameter. Plz reply to this question. Thanks in Advance atul
In addition to DavidCrow's reply - if the parameter for SetItemData() is a DWORD_PTR, use that instead of a DWORD in the cast. Mark
Mark Salsbery Microsoft MVP - Visual C++ :java: