在VC工程中我有一目录包含一些BMP文件,但我不想将BMP文件作为资源(即无固定的ID),如何将这些BMP文件用作ListCtrl的图标?

解决方案 »

  1.   

    LoadImage
    CImageList::Add
    CListCtrl::SetImageList
      

  2.   

    there is an example using ico file:
    > 1) Create an empty CImageList

    >   m_MyIconList.Create (IDB_ICONS, GetSystemMetrics (SM_CXICON),
    >         1, RGB (255,255,255));

    > 2) do loopy load the images via e.g.

    >   HICON hIcon= (HICON) LoadImage
    >         (AfxGetInstanceHandle(),
    >          "anicon.ico", // your filenames goes here
    >          IMAGE_ICON, 0, 0, LR_LOADFROMFILE);

    > 3) add it to the ImageList with e.g.

    >   if (hIcon) m_MyIconList.Add (hIcon);