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 generate a new icon at runtime for MFC tree control

How to generate a new icon at runtime for MFC tree control

Scheduled Pinned Locked Moved C / C++ / MFC
c++data-structurestutorialquestion
4 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.
  • L Offline
    L Offline
    lastgen
    wrote on last edited by
    #1

    I know how to change an icon, I was just wondering if anybody knows how to generate new icons at runtime, or ideally how to create a new icon identical to the previous but with different colours? Alternatively, is it possible to change display colours of an icon without creating a new one? When I die I'd like to go peacefully in my sleep like my father, not screaming in terror like his passengers!!!

    S H 3 Replies Last reply
    0
    • L lastgen

      I know how to change an icon, I was just wondering if anybody knows how to generate new icons at runtime, or ideally how to create a new icon identical to the previous but with different colours? Alternatively, is it possible to change display colours of an icon without creating a new one? When I die I'd like to go peacefully in my sleep like my father, not screaming in terror like his passengers!!!

      S Offline
      S Offline
      Stephen Hewitt
      wrote on last edited by
      #2

      You can create a bitmap using the CreateBitmap API. Then you can use GDI to draw to it. Then you add it to the image list of the tree control using the ImageList_Add function. MFC has wrappers for there APIs. Steve

      1 Reply Last reply
      0
      • L lastgen

        I know how to change an icon, I was just wondering if anybody knows how to generate new icons at runtime, or ideally how to create a new icon identical to the previous but with different colours? Alternatively, is it possible to change display colours of an icon without creating a new one? When I die I'd like to go peacefully in my sleep like my father, not screaming in terror like his passengers!!!

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

        CImageList *m_ImageTree; TV_INSERTSTRUCT TreeItem; HTREEITEM hTreeItem; CBitmap bit; m_ImageTree = new CImageList(); m_ImageTree->Create(15,15, ILC_COLORDDB,0,0); TreeItem.hParent = TVI_ROOT; TreeItem.hInsertAfter = TVI_LAST; TreeItem.item.mask = TVIF_TEXT | TVIF_PARAM|TVIF_IMAGE|TVIF_SELECTEDIMAGE; TreeItem.item.pszText = _T("TEST"); TreeItem.item.lParam = 0; TreeItem.item.iImage=0; TreeItem.item.iSelectedImage=0; hTreeItem = m_Tree1.InsertItem(&TreeItem); bit.LoadBitmap(IDB_BITMAP1); m_ImageTree->Add(&bit,RGB(255,0,255)); m_Tree1.SetImageList(m_ImageTree, LVSIL_NORMAL);

        1 Reply Last reply
        0
        • L lastgen

          I know how to change an icon, I was just wondering if anybody knows how to generate new icons at runtime, or ideally how to create a new icon identical to the previous but with different colours? Alternatively, is it possible to change display colours of an icon without creating a new one? When I die I'd like to go peacefully in my sleep like my father, not screaming in terror like his passengers!!!

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

          and you can replace HBITMAP hBmp = (HBITMAP)LoadImage(NULL,"c:\\a.bmp", IMAGE_BITMAP,0,0,LR_LOADFROMFILE|LR_CREATEDIBSECTION); bit.Attach(hBmp); instead bit.LoadBitmap(IDB_BITMAP1);

          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