我做了个控件,其中有两个属性页上用到了list view,为了某些目的,我在这两个list上使用了image list来做标识,现在遇到的问题时,如果我某次接连打开了这两个属性页后,关闭属性页再次打开时会出现异常,好像是在Attach(ImageList_LoadBitmap(hInst,(LPCTSTR)nBitmapID, cx, nGrow, crMask))时出错了,请问各位怎么解决.

解决方案 »

  1.   

    1.Attach连接对象不能为null
    2.Attach如果已经连接了一个对象,在没有和这个对象断开前再次使用Attach将会出错.
      

  2.   

    [email protected]
    方便的话发来看看.
      

  3.   

    不太方便发,给我的感觉就好像Detach时并为从HandleMap中释放掉原来的对象一样,其中一段代码如下:
    CImageList* PASCAL CImageList::FromHandlePermanent(HIMAGELIST h)
    {
       CHandleMap* pMap = afxMapHIMAGELIST();
       CImageList* pImageList = NULL;
       if (pMap != NULL)
       {
          // only look in the permanent map - does no allocations
          pImageList = (CImageList*)pMap->LookupPermanent(h);
          ASSERT(pImageList == NULL || pImageList->m_hImageList == h);
       }
       return pImageList;
    }
    只是MFC中的代码,LookupPermanent返回后pImageList不为空,且pImageList->m_hImageList != h,真是不知所谓啊.