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. dynamic CImageList icons - possible? [modified]

dynamic CImageList icons - possible? [modified]

Scheduled Pinned Locked Moved C / C++ / MFC
question
7 Posts 5 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
    neilsolent
    wrote on last edited by
    #1

    I have a CTreeCtrl and an associated CImageList. Is there any way I can load images into the CImageList at runtime (e.g. from an .ico file supplied by the user) without them being hardcoded into the executable files ? -- modified at 14:21 Thursday 4th January, 2007

    cheers, Neil

    M J CPalliniC H 4 Replies Last reply
    0
    • N neilsolent

      I have a CTreeCtrl and an associated CImageList. Is there any way I can load images into the CImageList at runtime (e.g. from an .ico file supplied by the user) without them being hardcoded into the executable files ? -- modified at 14:21 Thursday 4th January, 2007

      cheers, Neil

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

      You can add/remove images from image lists dynamically. Check out CImageList::Add() (::ImageList_AddIcon()), ::LoadImage(), etc. Mark

      1 Reply Last reply
      0
      • N neilsolent

        I have a CTreeCtrl and an associated CImageList. Is there any way I can load images into the CImageList at runtime (e.g. from an .ico file supplied by the user) without them being hardcoded into the executable files ? -- modified at 14:21 Thursday 4th January, 2007

        cheers, Neil

        J Offline
        J Offline
        James R Twine
        wrote on last edited by
        #3

        Yes - although if dealing with a lot of images it is better to initially size the ImageList control to hold a bunch of images.    The CImageList::GetImageInfo(...) function or the ImageList_GetImageInfo(...) macro can be used to write data into the images maintained by the ImageList control.    Peace!

        -=- James
        Please rate this message - let me know if I helped or not! * * * If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
        Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
        See DeleteFXPFiles

        1 Reply Last reply
        0
        • N neilsolent

          I have a CTreeCtrl and an associated CImageList. Is there any way I can load images into the CImageList at runtime (e.g. from an .ico file supplied by the user) without them being hardcoded into the executable files ? -- modified at 14:21 Thursday 4th January, 2007

          cheers, Neil

          CPalliniC Offline
          CPalliniC Offline
          CPallini
          wrote on last edited by
          #4

          see here Note: you can dynamically load an image using the LoadImage API.

          If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.

          In testa che avete, signor di Ceprano?

          1 Reply Last reply
          0
          • N neilsolent

            I have a CTreeCtrl and an associated CImageList. Is there any way I can load images into the CImageList at runtime (e.g. from an .ico file supplied by the user) without them being hardcoded into the executable files ? -- modified at 14:21 Thursday 4th January, 2007

            cheers, Neil

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

            Yes you have many good function in CImageList Add,Remove,Replace


            WhiteSky


            N 1 Reply Last reply
            0
            • H Hamid Taebi

              Yes you have many good function in CImageList Add,Remove,Replace


              WhiteSky


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

              Thanks to everyone for the posts. I know these functions, but they don't realy explain how to load icons from files or "external" data sources - this is what I meant by dynamic (the icons aren't already hardcoded as resources in the executables). I found the functions I was looking for, which are: ExtractIcon() - load icon from disk CreateIconFromResourceEx() - load icon from memory Sorry, I think I should have explained what I was after a bit better..

              cheers, Neil

              H 1 Reply Last reply
              0
              • N neilsolent

                Thanks to everyone for the posts. I know these functions, but they don't realy explain how to load icons from files or "external" data sources - this is what I meant by dynamic (the icons aren't already hardcoded as resources in the executables). I found the functions I was looking for, which are: ExtractIcon() - load icon from disk CreateIconFromResourceEx() - load icon from memory Sorry, I think I should have explained what I was after a bit better..

                cheers, Neil

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

                I think you need to SHGetFileInfo to get information about file and... and also if you dont know about CImageList and its functions search on the codeproject it has a lot of good articles :)


                WhiteSky


                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