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

    MFC Tree Control: How to add multiple icons to a tree control item?

    Hi,

    I am trying to display multiple icons to the treeview item but it is not displaying all the icons, it displays only one.
    I am using CImageList m_imageState;

    m_cTree.m_imageState.Create(16, 16, ILC_MASK, 0, 4);
    m_cTree.m_imageState.Add(&bm, RGB(255,255,0));
    m_cTree.m_imageState.Add(&bm2, RGB(255,0,255));
    m_cTree.m_imageState.Add(&bm, RGB(255,255,0));
    m_cTree.m_imageState.Add(&bm1, RGB(0,255,255));

    But when i see treeview item it displays only one icon.

    Is it possible to display multiple icons with treeview item?

    Please suggest how can i do this.

    Thanks

  2. #2
    Join Date
    Apr 2011
    Posts
    4

    Re: MFC Tree Control: How to add multiple icons to a tree control item?

    Hi,

    I am trying to display multiple icons to the Treeview item but it is not displaying all the icons, it displays only one.
    I am using CImageList m_imageState;

    m_cTree.m_imageState.Create(16, 16, ILC_MASK, 0, 4);
    m_cTree.m_imageState.Add(&bm, RGB(255,255,0));
    m_cTree.m_imageState.Add(&bm2, RGB(255,0,255));
    m_cTree.m_imageState.Add(&bm, RGB(255,255,0));
    m_cTree.m_imageState.Add(&bm1, RGB(0,255,255));

    m_cTree.SetImageList( &(m_cTree.m_imageState), TVSIL_NORMAL );

    But when I see Treeview, item displays only one icon.

    Is it possible to display multiple icons with Treeview item?

    Please suggest how can i do this.

    Thanks

  3. #3
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: MFC Tree Control: How to add multiple icons to a tree control item?

    You can use two images: "normal: and "state". To implement state images you have to set the TVSIL_STATE image list. (The state images are usually used as the check marks for the control with TVS_CHECKBOXES style)
    Victor Nijegorodov

  4. #4
    Join Date
    Apr 2011
    Posts
    4

    Re: MFC Tree Control: How to add multiple icons to a tree control item?

    Quote Originally Posted by VictorN View Post
    You can use two images: "normal: and "state". To implement state images you have to set the TVSIL_STATE image list. (The state images are usually used as the check marks for the control with TVS_CHECKBOXES style)

    I have tried with the TVSIL_STATE and it displays the check boxes but this change still doesn't display multiple images at tree view item.

  5. #5
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: MFC Tree Control: How to add multiple icons to a tree control item?

    Then you will have to use custom draw and draw the whole control yourself.
    Victor Nijegorodov

  6. #6
    Join Date
    Apr 2011
    Posts
    4

    Re: MFC Tree Control: How to add multiple icons to a tree control item?

    Quote Originally Posted by VictorN View Post
    Then you will have to use custom draw and draw the whole control yourself.
    Thanks for your reply....


    My treeview could contain thousand of items and each tree view item can contain multiple images.
    I can draw the individual icons into a bitmap in memory, then load that bitmap into the ImageList.
    But In this scenario I feel that drawing the treeview with custom draw would be a very costly operation???

    your suggestion please??

  7. #7
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: MFC Tree Control: How to add multiple icons to a tree control item?

    Quote Originally Posted by sisodia.nikhil View Post
    ... I feel that drawing the treeview with custom draw would be a very costly operation???
    No, unless you will do something wrong.
    It doesn't matter who will provide drawing: you yourself or the Windows for you.
    Victor Nijegorodov

Tags for this Thread

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