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. CImageList and a CListCtrl

CImageList and a CListCtrl

Scheduled Pinned Locked Moved C / C++ / MFC
tutoriallearning
6 Posts 4 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.
  • L Offline
    L Offline
    locoone
    wrote on last edited by
    #1

    i am in need of how to add the checkbox image to the header of a CListCtrl i have a child dialog in the main dialog ive looked in msdn but im lost CImageList * imagelist; CHeaderCtrl * m_pHdrCtrl; imagelist = new CImageList(); ASSERT(imagelist != NULL); imagelist->Create(13, 13, ILC_COLOR24, 3, 1); CBitmap bm; bm.LoadBitmap(IDB_CHECKBOXES); imagelist->Add(&bm, RGB(255, 0, 255)); m_pHdrCtrl->SetImageList(imagelist); that gives no errors on compiling it m_pHdrCtrl->SetImageList(imagelist); <-- wont allow me to build the exe im a beginner be gentle when telling me how wrong it is :sigh: i cant figure out how to add the imagelist to the header.

    N H S 3 Replies Last reply
    0
    • L locoone

      i am in need of how to add the checkbox image to the header of a CListCtrl i have a child dialog in the main dialog ive looked in msdn but im lost CImageList * imagelist; CHeaderCtrl * m_pHdrCtrl; imagelist = new CImageList(); ASSERT(imagelist != NULL); imagelist->Create(13, 13, ILC_COLOR24, 3, 1); CBitmap bm; bm.LoadBitmap(IDB_CHECKBOXES); imagelist->Add(&bm, RGB(255, 0, 255)); m_pHdrCtrl->SetImageList(imagelist); that gives no errors on compiling it m_pHdrCtrl->SetImageList(imagelist); <-- wont allow me to build the exe im a beginner be gentle when telling me how wrong it is :sigh: i cant figure out how to add the imagelist to the header.

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

      locoone wrote:

      m_pHdrCtrl->SetImageList(imagelist); <-- wont allow me to build the exe

      What do you mean? After puttin the above statement your not getting the output exe?

      nave [OpenedFileFinder]

      L 1 Reply Last reply
      0
      • L locoone

        i am in need of how to add the checkbox image to the header of a CListCtrl i have a child dialog in the main dialog ive looked in msdn but im lost CImageList * imagelist; CHeaderCtrl * m_pHdrCtrl; imagelist = new CImageList(); ASSERT(imagelist != NULL); imagelist->Create(13, 13, ILC_COLOR24, 3, 1); CBitmap bm; bm.LoadBitmap(IDB_CHECKBOXES); imagelist->Add(&bm, RGB(255, 0, 255)); m_pHdrCtrl->SetImageList(imagelist); that gives no errors on compiling it m_pHdrCtrl->SetImageList(imagelist); <-- wont allow me to build the exe im a beginner be gentle when telling me how wrong it is :sigh: i cant figure out how to add the imagelist to the header.

        H Offline
        H Offline
        Hamid Taebi
        wrote on last edited by
        #3

        See XListCtrl - A custom-draw list control with subitem formatting[^] does helpful?


        WhiteSky


        1 Reply Last reply
        0
        • L locoone

          i am in need of how to add the checkbox image to the header of a CListCtrl i have a child dialog in the main dialog ive looked in msdn but im lost CImageList * imagelist; CHeaderCtrl * m_pHdrCtrl; imagelist = new CImageList(); ASSERT(imagelist != NULL); imagelist->Create(13, 13, ILC_COLOR24, 3, 1); CBitmap bm; bm.LoadBitmap(IDB_CHECKBOXES); imagelist->Add(&bm, RGB(255, 0, 255)); m_pHdrCtrl->SetImageList(imagelist); that gives no errors on compiling it m_pHdrCtrl->SetImageList(imagelist); <-- wont allow me to build the exe im a beginner be gentle when telling me how wrong it is :sigh: i cant figure out how to add the imagelist to the header.

          S Offline
          S Offline
          sps itsec46
          wrote on last edited by
          #4

          Hi, if this is the code you wrote it cannot work. You declared a pointer to CHeaderCtrl and some lines below you access this pointer which you never set. This code compiles fine but certainly it results in a crash! You have to ask your CListCtrl instance for the pointer to its header control... Try the following:

          CHeaderCtrl* m_pHdrCtrl = m_YourListCtrl.GetHeaderCtrl();
          if(m_pHdrCtrl != NULL)
          {
          CImageList * imagelist;
          imagelist = new CImageList();
          ASSERT(imagelist != NULL);
          imagelist->Create(13, 13, ILC_COLOR24, 3, 1);
          CBitmap bm;
          bm.LoadBitmap(IDB_CHECKBOXES);
          imagelist->Add(&bm, RGB(255, 0, 255));
          m_pHdrCtrl->SetImageList(imagelist);
          }

          cheers, mykel OMM: "Let us be thankful we have an occupation to fill. Work hard, increase production, prevent accidents and be happy."

          1 Reply Last reply
          0
          • N Naveen

            locoone wrote:

            m_pHdrCtrl->SetImageList(imagelist); <-- wont allow me to build the exe

            What do you mean? After puttin the above statement your not getting the output exe?

            nave [OpenedFileFinder]

            L Offline
            L Offline
            locoone
            wrote on last edited by
            #5

            it crashes.

            N 1 Reply Last reply
            0
            • L locoone

              it crashes.

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

              now only i noticed you are not assigning any thing in to the CHeaderCtrl * m_pHdrCtrl; you must call the GetHeaderCtrl() function and set that pointer to the m_pHdrCtrl. like CHeaderCtrl * m_pHdrCtrl = m_ListCTrl.GetHeaderCtrl();

              nave [OpenedFileFinder]

              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