请教ImageList_Add函数怎么使用?    hImageList = ImageList_Create(16, 16, ILC_COLOR24, 10, 10)
    Debug.Print "ImageList_Add="; ImageList_Add(hImageList, Me.Icon.Handle, 0)
'这里返回-1,调用失败。    Debug.Print "Count="; ImageList_GetImageCount(hImageList)
'返回0
    ImageList_Destroy hImageList

解决方案 »

  1.   

    ImageList_Add是用来将位图(Bitmap)加入ImageList的(以前ToolBar用一个很长的位图来存储所有图标)向ImageList增加图标应该用ImageList_ReplaceIconCall ImageList_ReplaceIcon(hImageList, -1, Me.Icon.Handle)
      

  2.   

    MSDN:
    ImageList_AddIcon
    int ImageList_AddIcon(
        HIMAGELIST himl,
        HICON hicon
       ); Adds an icon or cursor to an image list. ImageList_AddIcon calls the ImageList_ReplaceIcon function. Returns the index of the new image if successful, or -1 otherwise. 
    himl 
    Handle to the image list. If this parameter identifies a masked image list, the macro copies both the image and mask bitmaps of the icon or cursor. If this parameter identifies a nonmasked image list, the macro copies only the image bitmap. 
    hicon 
    Handle to the icon or cursor that contains the bitmap and mask for the new image. 
    Because the system does not save hicon, you can destroy it after the macro returns if the icon or cursor was created by theCreateIcon function. You do not need to destroy hicon if it was loaded by theLoadIcon function; the system automatically frees an icon resource when it is no longer needed. The ImageList_AddIcon macro is defined as follows: #define  ImageList_AddIcon(himl, hicon) ImageList_ReplaceIcon(himl, -1, hicon)
     ImageList_ReplaceIcon
    int ImageList_ReplaceIcon(
        HIMAGELIST himl, 
        int i, 
        HICON hicon
       ); Replaces an image with an icon or cursor. Returns the index of the image if successful, or -1 otherwise. 
    himl 
    Handle to the image list. 

    Index of the image to replace. If i is -1, the function appends the image to the end of the list. 
    hicon 
    Handle to the icon or cursor that contains the bitmap and mask for the new image. 
    Because the system does not save hicon, you can destroy it after the function returns if the icon or cursor was created by theCreateIcon function. You do not need to destroy hicon if it was loaded by theLoadIcon function; the system automatically frees an icon resource when it is no longer needed.