Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to identify image in ListCtrl

How to identify image in ListCtrl

Scheduled Pinned Locked Moved C / C++ / MFC
tutorial
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Atul23
    wrote on last edited by
    #1

    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

    D 1 Reply Last reply
    0
    • A Atul23

      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

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      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, call GetItemData().


      "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

      A 1 Reply Last reply
      0
      • D David Crow

        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, call GetItemData().


        "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

        A Offline
        A Offline
        Atul23
        wrote on last edited by
        #3

        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

        D M 2 Replies Last reply
        0
        • A Atul23

          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

          D Offline
          D Offline
          David Crow
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          • A Atul23

            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

            M Offline
            M Offline
            Mark Salsbery
            wrote on last edited by
            #5

            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:

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups