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. VC++ 6.0 SetupDiGetClassImageList query

VC++ 6.0 SetupDiGetClassImageList query

Scheduled Pinned Locked Moved C / C++ / MFC
c++sharepointdatabasedata-structureshelp
7 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.
  • C Offline
    C Offline
    callousfantom
    wrote on last edited by
    #1

    Hi.Does anyone know how to cast an SP_CLASSIMAGELIST_DATA structure to CImageList class? Is it possible? I'm guessing it should be but can't seem to be able to do it. Actually I've retrieved an imagelist of all devices using SetupDiGetClassImageList function into a SP_CLASSIMAGELIST_DATA structure. I'm now trying to set it to be the imageList of my Tree Control that lists the devices. However due to these casting issues I get a runtime assertion error and my application crashes. Any ideas? I've tried the following methods but have failed with the same runtime error. Method 1: <i>PSP_CLASSIMAGELIST_DATA imageList; SetupDiGetClassImageList(imageList); <b>m_Tree.SetImageList((CImageList *)imageList->ImageList,TVSIL_NORMAL);</b></i> Method 2: <i>PSP_CLASSIMAGELIST_DATA imageList; CImageList imList; SetupDiGetClassImageList(imageList); <b>imList.Attach(imageList->ImageList); m_Tree.SetImageList(imList,TVSIL_NORMAL);</b></i> I have bolded the lines that are causing the crash.

    N 1 Reply Last reply
    0
    • C callousfantom

      Hi.Does anyone know how to cast an SP_CLASSIMAGELIST_DATA structure to CImageList class? Is it possible? I'm guessing it should be but can't seem to be able to do it. Actually I've retrieved an imagelist of all devices using SetupDiGetClassImageList function into a SP_CLASSIMAGELIST_DATA structure. I'm now trying to set it to be the imageList of my Tree Control that lists the devices. However due to these casting issues I get a runtime assertion error and my application crashes. Any ideas? I've tried the following methods but have failed with the same runtime error. Method 1: <i>PSP_CLASSIMAGELIST_DATA imageList; SetupDiGetClassImageList(imageList); <b>m_Tree.SetImageList((CImageList *)imageList->ImageList,TVSIL_NORMAL);</b></i> Method 2: <i>PSP_CLASSIMAGELIST_DATA imageList; CImageList imList; SetupDiGetClassImageList(imageList); <b>imList.Attach(imageList->ImageList); m_Tree.SetImageList(imList,TVSIL_NORMAL);</b></i> I have bolded the lines that are causing the crash.

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

      Can you show me the definition of CImageList and PSP_CLASSIMAGELIST_DATA?

      C 1 Reply Last reply
      0
      • N norish

        Can you show me the definition of CImageList and PSP_CLASSIMAGELIST_DATA?

        C Offline
        C Offline
        callousfantom
        wrote on last edited by
        #3

        Hey, I've added all the code relevant to retreival of ImageList below. There is nothing other than this in my code. Please have a look and let me know what modifications it would require. Thanks!:) Code: PSP_CLASSIMAGELIST_DATA imageList={0};int imIndex; CImageList imList; imageList->cbSize=sizeof(SP_CLASSIMAGELIST_DATA); SetupDiGetClassImageList(imageList); imList.Attach(imageList->ImageList); m_Tree.SetImageList(&imList,TVSIL_NORMAL); /*devInfo is a valid SP_DEVINFO_DATA structure.I know this because the tree control shows the correct output(without any images though)*/ SetupDiGetClassImageIndex(imageList,&devInfo.ClassGuid,&imIndex); I later use imIndex to set the iImage property of TVITEM structure. This is node that is later inserted into the tree.

        N P 2 Replies Last reply
        0
        • C callousfantom

          Hey, I've added all the code relevant to retreival of ImageList below. There is nothing other than this in my code. Please have a look and let me know what modifications it would require. Thanks!:) Code: PSP_CLASSIMAGELIST_DATA imageList={0};int imIndex; CImageList imList; imageList->cbSize=sizeof(SP_CLASSIMAGELIST_DATA); SetupDiGetClassImageList(imageList); imList.Attach(imageList->ImageList); m_Tree.SetImageList(&imList,TVSIL_NORMAL); /*devInfo is a valid SP_DEVINFO_DATA structure.I know this because the tree control shows the correct output(without any images though)*/ SetupDiGetClassImageIndex(imageList,&devInfo.ClassGuid,&imIndex); I later use imIndex to set the iImage property of TVITEM structure. This is node that is later inserted into the tree.

          N Offline
          N Offline
          norish
          wrote on last edited by
          #4

          So, m_Tree.SetImageList(&imList,TVSIL_NORMAL); caused a runtime error, you said? What kind of error you had at this time? If you had application error like 0xc0000005, some pointer maybe invalid. Other error, I cannot imagine the situation at this time.

          C 1 Reply Last reply
          0
          • N norish

            So, m_Tree.SetImageList(&imList,TVSIL_NORMAL); caused a runtime error, you said? What kind of error you had at this time? If you had application error like 0xc0000005, some pointer maybe invalid. Other error, I cannot imagine the situation at this time.

            C Offline
            C Offline
            callousfantom
            wrote on last edited by
            #5

            Yes it is an application error where it refers to some address claiming the memory could not be "read". However, if that statement is commented out all seems to run fine. So all I can conclude from this is that the problem lies in these 2 code statements of Attach and SetImageList functions. I really can't figure out what could possibly be causing this and am really close to giving up on the idea of adding images! Please Help!:confused: Exactly the error is as follows: The instruction at "0x00405652" referenced memory at "0x00000004".The memory could not be "read".

            modified on Friday, June 19, 2009 2:27 AM

            N 1 Reply Last reply
            0
            • C callousfantom

              Yes it is an application error where it refers to some address claiming the memory could not be "read". However, if that statement is commented out all seems to run fine. So all I can conclude from this is that the problem lies in these 2 code statements of Attach and SetImageList functions. I really can't figure out what could possibly be causing this and am really close to giving up on the idea of adding images! Please Help!:confused: Exactly the error is as follows: The instruction at "0x00405652" referenced memory at "0x00000004".The memory could not be "read".

              modified on Friday, June 19, 2009 2:27 AM

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

              > referenced memory at "0x00000004". This usually means that offset 4 of pointer which points null is not accessible. So you can check the member whether null or not of imList. If you use visual studio IDE, you can step into codes and can check any data is null or not.

              1 Reply Last reply
              0
              • C callousfantom

                Hey, I've added all the code relevant to retreival of ImageList below. There is nothing other than this in my code. Please have a look and let me know what modifications it would require. Thanks!:) Code: PSP_CLASSIMAGELIST_DATA imageList={0};int imIndex; CImageList imList; imageList->cbSize=sizeof(SP_CLASSIMAGELIST_DATA); SetupDiGetClassImageList(imageList); imList.Attach(imageList->ImageList); m_Tree.SetImageList(&imList,TVSIL_NORMAL); /*devInfo is a valid SP_DEVINFO_DATA structure.I know this because the tree control shows the correct output(without any images though)*/ SetupDiGetClassImageIndex(imageList,&devInfo.ClassGuid,&imIndex); I later use imIndex to set the iImage property of TVITEM structure. This is node that is later inserted into the tree.

                P Offline
                P Offline
                Po Yu
                wrote on last edited by
                #7

                Hey, I think that I've found a problem in your code. Please see the modified code below, SP_CLASSIMAGELIST_DATA imageList = {0}; int imIndex; CImageList imList; imageList.cbSize=sizeof(SP_CLASSIMAGELIST_DATA); SetupDiGetClassImageList(&imageList); imList.Attach(imageList.ImageList); m_Tree.SetImageList(&imList,TVSIL_NORMAL); Hope it helps.. :)

                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