CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 1999
    Posts
    6

    A question about displaying image

    I created an image list named m_imageList.after that,I add one bitmap and one icon to it.When I add items with the images to a list control,I met a problem. I found I can add icon successfully,but can't for bitmap.
    I list the codes in the follow:

    1. Create the image list with 100*100 icons and 32 bpp color depth
    HIMAGELIST hImageList=ImageList_Create(100, 100, ILC_COLOR32, 0, 10);
    m_imageList.Attach(hImageList);

    // load the starting bitmap ("Loading..." and "Corrupt file")
    CBitmap dummy;
    dummy.LoadBitmap(IDB_NAILS100);
    m_imageList.Add(&dummy, RGB(0, 0, 0));
    m_imageList.Add(AfxGetApp()->LoadIcon(IDR_MAINFRAME));

    // Use the image list in the list view
    GetListCtrl().SetImageList(&m_imageList, LVSIL_NORMAL);
    GetListCtrl().SetImageList(&m_imageList, LVSIL_SMALL);


    2. Adding items to the list control
    GetListCtrl().InsertColumn(0,"goodhead",LVCFMT_LEFT,-1,0);
    int imgPos=0;
    GetListCtrl().InsertItem(LVIF_IMAGE|LVIF_TEXT,0,"bitmap",0,0,imgPos,0);
    imgPos=1;
    GetListCtrl().InsertItem(LVIF_IMAGE|LVIF_TEXT,1,"icon",0,0,imgPos,0);

    3. Result
    I can see the icon image in the list,but where is the bitmap image? I don't know.

    Thank you for your help!



  2. #2
    Join Date
    May 1999
    Location
    Toulouse, France
    Posts
    171

    Re: A question about displaying image

    1) I don't understand why you use ImageList_Create, instead of MFC member functions, like this:

    // if previouly created, use m_Imagelist.Detach()
    m_Imagelist.Create(IDB_NAILS100, 100, ILC_COLOR32, RGB(0, 0, 0));

    2) Following the documentation:
    "An "image list" is a collection of same-sized images, each of which can be referred to by its zero-based index. "; So you can't have in the same ImageList a bitmap of 100x100 and an icon, which is probably 32x32;

    3) you may check the number of images in your image list when you add one (return value of Add = previous image count)

    HTH.

    K.

    Ash to ash and clay to clay, if the enemy doesn't get you, your own folk may.
    We're talking ****, 'cause life is a 'biz
    You know it is
    Everybody tryin' to get rich
    God ****!
    All I wanna do is live !

    KoRn, Children of the Korn

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured