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 get the image from a clistctrl?

How to get the image from a clistctrl?

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
7 Posts 2 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.
  • S Offline
    S Offline
    shibble
    wrote on last edited by
    #1

    Hi, i need to get the imagenumber from a clistctrl on which i added a imagelist. At the OnDoubleClick event i need to get the imagenumber from the selected item. Is there any way to retrieve the number? I want to compare like if (imagenumber == CONST_BITMAP_FOLDER) { Send next command } thx!

    R 1 Reply Last reply
    0
    • S shibble

      Hi, i need to get the imagenumber from a clistctrl on which i added a imagelist. At the OnDoubleClick event i need to get the imagenumber from the selected item. Is there any way to retrieve the number? I want to compare like if (imagenumber == CONST_BITMAP_FOLDER) { Send next command } thx!

      R Offline
      R Offline
      Ravi Bhavnani
      wrote on last edited by
      #2

      See CListCtrl::GetItem() and LVITEM. /ravi My new year's resolution: 2048 x 1536 Home | Articles | Freeware | Music ravib@ravib.com

      S 1 Reply Last reply
      0
      • R Ravi Bhavnani

        See CListCtrl::GetItem() and LVITEM. /ravi My new year's resolution: 2048 x 1536 Home | Articles | Freeware | Music ravib@ravib.com

        S Offline
        S Offline
        shibble
        wrote on last edited by
        #3

        I do this @ doubleclick event: LVITEM lvi; int nimage; int nitem; nitem=m_ctlServerList.GetSelectionMark(); m_ctlServerList.GetItem(&lvi); nimage=lvi.iImage; The Problem is lvi.iImage returns always 0.

        R 1 Reply Last reply
        0
        • S shibble

          I do this @ doubleclick event: LVITEM lvi; int nimage; int nitem; nitem=m_ctlServerList.GetSelectionMark(); m_ctlServerList.GetItem(&lvi); nimage=lvi.iImage; The Problem is lvi.iImage returns always 0.

          R Offline
          R Offline
          Ravi Bhavnani
          wrote on last edited by
          #4

          Couple of comments:

          1. You should intialize lvi to zero to ensure the code works correctly in release mode.
          2. You need to do lvi.mask = LVIF_IMAGE; before calling GetItem().

          Hope this helps! /ravi My new year's resolution: 2048 x 1536 Home | Articles | Freeware | Music ravib@ravib.com

          S 1 Reply Last reply
          0
          • R Ravi Bhavnani

            Couple of comments:

            1. You should intialize lvi to zero to ensure the code works correctly in release mode.
            2. You need to do lvi.mask = LVIF_IMAGE; before calling GetItem().

            Hope this helps! /ravi My new year's resolution: 2048 x 1536 Home | Articles | Freeware | Music ravib@ravib.com

            S Offline
            S Offline
            shibble
            wrote on last edited by
            #5

            Yeah it works fine! thx! I got a new problem. I Fill a list control with stuff which is todo, i call it todolist. The size of the ctrl displays 3 items without scrolling (item count varies). I want to scroll to the current proccess item. I´ve tried alot but didnt get any good result. Here´s a code snipped: m_nTodoItem=nitem; //Scrolling m_pCtlListTodo->GetItemRect(0,rect,LVIR_ICON); size.cy=0; //m_pCtlListTodo->Scroll(-5000); size.cy=nitem * rect.Height(); //scrollpos=m_pCtlListTodo->GetScrollPos(SB_VERT); //size.cy-=scrollpos; m_pCtlListTodo->SetScrollPos(SB_VERT,0); m_pCtlListTodo->Scroll(size); //scrollpos=rect.Height(); m_pCtlListTodo->Scroll(size); //m_pCtlListTodo->SetScrollPos(SB_VERT,scrollpos); m_pCtlListTodo->SetSelectionMark(nitem); Sometimes just the bars scroll without the content. How to scroll dynamicly with considering user actions. Thx alot for help and sorry for bad english.

            R 1 Reply Last reply
            0
            • S shibble

              Yeah it works fine! thx! I got a new problem. I Fill a list control with stuff which is todo, i call it todolist. The size of the ctrl displays 3 items without scrolling (item count varies). I want to scroll to the current proccess item. I´ve tried alot but didnt get any good result. Here´s a code snipped: m_nTodoItem=nitem; //Scrolling m_pCtlListTodo->GetItemRect(0,rect,LVIR_ICON); size.cy=0; //m_pCtlListTodo->Scroll(-5000); size.cy=nitem * rect.Height(); //scrollpos=m_pCtlListTodo->GetScrollPos(SB_VERT); //size.cy-=scrollpos; m_pCtlListTodo->SetScrollPos(SB_VERT,0); m_pCtlListTodo->Scroll(size); //scrollpos=rect.Height(); m_pCtlListTodo->Scroll(size); //m_pCtlListTodo->SetScrollPos(SB_VERT,scrollpos); m_pCtlListTodo->SetSelectionMark(nitem); Sometimes just the bars scroll without the content. How to scroll dynamicly with considering user actions. Thx alot for help and sorry for bad english.

              R Offline
              R Offline
              Ravi Bhavnani
              wrote on last edited by
              #6

              shibble wrote: I want to scroll to the current proccess item. Assuming you know the index of the item, you can call CListCtrl::EnsureVisible(). /ravi My new year's resolution: 2048 x 1536 Home | Articles | Freeware | Music ravib@ravib.com

              S 1 Reply Last reply
              0
              • R Ravi Bhavnani

                shibble wrote: I want to scroll to the current proccess item. Assuming you know the index of the item, you can call CListCtrl::EnsureVisible(). /ravi My new year's resolution: 2048 x 1536 Home | Articles | Freeware | Music ravib@ravib.com

                S Offline
                S Offline
                shibble
                wrote on last edited by
                #7

                Great,great,great!!!!! 3 Hours of testing with those cra** scrollbars, its just one function.. Thx alot!!!!!!!!!

                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