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. Problem with CListCtrl::InsertColumn

Problem with CListCtrl::InsertColumn

Scheduled Pinned Locked Moved C / C++ / MFC
databasehelpquestion
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.
  • N Offline
    N Offline
    Naveen
    wrote on last edited by
    #1

    Hi, I have problem with inserting image in the HeaderCtrl of CListCtrl.. I tried to insert a column a follows InsertColumn( 0, "text", LVCFMT_LEFT, 100 ); soon after this statement I called the GetItem of the headerctrl as follows HDITEM stHeaderItem = {0}; stHeaderItem.mask = HDI_IMAGE; stHeaderItem.iImage = -1; GetHeaderCtrl.GetItem( 0, &stHeaderItem ); Now I am getting the image index as 0.The expected result is -1( Since i haven't set any image). Why this is happening? nave

    L G 2 Replies Last reply
    0
    • N Naveen

      Hi, I have problem with inserting image in the HeaderCtrl of CListCtrl.. I tried to insert a column a follows InsertColumn( 0, "text", LVCFMT_LEFT, 100 ); soon after this statement I called the GetItem of the headerctrl as follows HDITEM stHeaderItem = {0}; stHeaderItem.mask = HDI_IMAGE; stHeaderItem.iImage = -1; GetHeaderCtrl.GetItem( 0, &stHeaderItem ); Now I am getting the image index as 0.The expected result is -1( Since i haven't set any image). Why this is happening? nave

      L Offline
      L Offline
      Laxman Auti
      wrote on last edited by
      #2

      iImage parameter is the Zero-based index of an image within the image list no matter you are setting image or not Knock out 'T' from CAN'T , You 'CAN' if you think you 'CAN' :cool:

      N 1 Reply Last reply
      0
      • L Laxman Auti

        iImage parameter is the Zero-based index of an image within the image list no matter you are setting image or not Knock out 'T' from CAN'T , You 'CAN' if you think you 'CAN' :cool:

        N Offline
        N Offline
        Naveen
        wrote on last edited by
        #3

        By setting image I mean setting the Iimage member of the LVCOLUMN structure nave

        1 Reply Last reply
        0
        • N Naveen

          Hi, I have problem with inserting image in the HeaderCtrl of CListCtrl.. I tried to insert a column a follows InsertColumn( 0, "text", LVCFMT_LEFT, 100 ); soon after this statement I called the GetItem of the headerctrl as follows HDITEM stHeaderItem = {0}; stHeaderItem.mask = HDI_IMAGE; stHeaderItem.iImage = -1; GetHeaderCtrl.GetItem( 0, &stHeaderItem ); Now I am getting the image index as 0.The expected result is -1( Since i haven't set any image). Why this is happening? nave

          G Offline
          G Offline
          Ganesh_T
          wrote on last edited by
          #4

          Try Using this: CImageList *ImgHeaders = new CImageList; ImgHeaders->Create(Bitmap ID, 16, 3, RGB(255, 0, 255)); // iterate through header items and attach the image list HDITEM hditem; CHeaderCtrl *headerCtrl; headerCtrl = new CHeaderCtrl(); headerCtrl = m_pScanList.GetHeaderCtrl(); headerCtrl->SetImageList(ImgHeaders); for (int i = 0; i < headerCtrl->GetItemCount(); i++) { hditem.mask = HDI_IMAGE | HDI_FORMAT; headerCtrl->GetItem(i, &hditem); hditem.fmt |= HDF_IMAGE; if (i == 0 ) hditem.iImage = Image ID; else hditem.iImage = Image ID; headerCtrl->SetItem(i, &hditem); } Cheers "Peace of mind through Technology"

          N 1 Reply Last reply
          0
          • G Ganesh_T

            Try Using this: CImageList *ImgHeaders = new CImageList; ImgHeaders->Create(Bitmap ID, 16, 3, RGB(255, 0, 255)); // iterate through header items and attach the image list HDITEM hditem; CHeaderCtrl *headerCtrl; headerCtrl = new CHeaderCtrl(); headerCtrl = m_pScanList.GetHeaderCtrl(); headerCtrl->SetImageList(ImgHeaders); for (int i = 0; i < headerCtrl->GetItemCount(); i++) { hditem.mask = HDI_IMAGE | HDI_FORMAT; headerCtrl->GetItem(i, &hditem); hditem.fmt |= HDF_IMAGE; if (i == 0 ) hditem.iImage = Image ID; else hditem.iImage = Image ID; headerCtrl->SetItem(i, &hditem); } Cheers "Peace of mind through Technology"

            N Offline
            N Offline
            Naveen
            wrote on last edited by
            #5

            What happens if I explicitly set the image number to 0 while inserting? By the above code I cannot distinguish them..isn’t it? nave

            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