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

    Unhappy iam not able to view the images in the tree

    hi all

    iam not able to view the images loaded in the tree

    but the space for the image is allocated but can not view it

    i have added a bitmap and also created the imagelist but iam not able to

    view it....

    CImageList m_TreeImg;
    m_TreeImg.Create(IDB_BITMAP, 16, 5, RGB(255, 255, 255));
    m_Tree.SetImageList(&m_TreeImg, TVSIL_NORMAL);

    HTREEITEM hCompany, hOffice, hProg, hOperSys, hProd;
    hCompany = m_Tree.InsertItem("Microsoft", 0, 5, TVI_ROOT);
    hOperSys = m_Tree.InsertItem("Windows 9x", 5, 1, hCompany);
    hOperSys = m_Tree.InsertItem("Windows NT", 5, 1, hCompany);
    hOffice = m_Tree.InsertItem("Office 97", 1, 4, hCompany);

    hProd = m_Tree.InsertItem("Word", 2, 3, hOffice);
    hProd = m_Tree.InsertItem("Access", 2, 3, hOffice);
    hProd = m_Tree.InsertItem("Excel", 2, 3, hOffice);
    hProd = m_Tree.InsertItem("OutLook", 2, 3, hOffice);
    hProd = m_Tree.InsertItem("PowerPoint", 2, 3, hOffice);

    hProg = m_Tree.InsertItem("Visual C++", 3, 4, hCompany);
    hProg = m_Tree.InsertItem("Visual Basic", 3, 4, hCompany);
    hProg = m_Tree.InsertItem("Visual FoxPro", 3, 4, hCompany);
    hProg = m_Tree.InsertItem("Visual Interdev", 3, 4, hCompany);


    and so on....

    Every thing is perfect

    only thing i cannot view the images even it has allocated the space for the image b4 the text of the tree items....

  2. #2
    Join Date
    Apr 2000
    Location
    Boston
    Posts
    124

    Re: iam not able to view the images in the tree

    This might be a silly question, but do you add images to m_TreeImg? From the code you posted, it looks like you are setting an empty image list to your tree control.

  3. #3
    Join Date
    Sep 2002
    Location
    14° 39'19.65"N / 121° 1'44.34"E
    Posts
    9,815

    Re: iam not able to view the images in the tree

    Quote Originally Posted by ganapathykumar
    CImageList m_TreeImg;
    m_TreeImg.Create(IDB_BITMAP, 16, 5, RGB(255, 255, 255));
    m_Tree.SetImageList(&m_TreeImg, TVSIL_NORMAL);
    That's somewhat confusing: The prefix (m_) suggests that m_TreeImg is a member variable of a class, but the code as you posted it looks like it was a local variable... So what is it? And if it is a local variable it won't work, since the image list will be destroyed when it goes out of scope.

  4. #4
    Join Date
    Sep 2002
    Location
    14° 39'19.65"N / 121° 1'44.34"E
    Posts
    9,815

    Re: iam not able to view the images in the tree

    Quote Originally Posted by mike200
    This might be a silly question, but do you add images to m_TreeImg? From the code you posted, it looks like you are setting an empty image list to your tree control.
    No, he loads the bitmaps from a resource (IDB_BITMAP).

  5. #5
    Join Date
    Feb 2005
    Posts
    29

    Re: iam not able to view the images in the tree

    thanx a lot sir i got it...

    and i have another question CMenu

    the code is as follows..


    void CMyDlg::OnContextMenu(CWnd* pWnd, CPoint point)
    {


    CMenu menu;

    menu.LoadMenu (IDR_MENU2);

    CMenu *pMenu=menu.GetSubMenu(0);

    pMenu->TrackPopupMenu (TPM_LEFTALIGN ,point.x,point.y,pWnd);
    }


    if i write any actions on the menu items to handle any operations of the dialog it is not working

    for eg when i rclick this menu popups how should i write code for the menu item so that i can exit or do any action for the dialog ...


    if i write code on the ::OnMenuItem() function it doesnt work...

    give me simple code to exit the dialog fro the context menu...

  6. #6
    Join Date
    Sep 2002
    Location
    14° 39'19.65"N / 121° 1'44.34"E
    Posts
    9,815

    Re: iam not able to view the images in the tree

    Quote Originally Posted by ganapathykumar
    thanx a lot sir i got it...
    And, what was it?

    Quote Originally Posted by ganapathykumar
    and i have another question CMenu
    You'd better start a new thread for that, since it is not related to your original question.

    Anyway:
    Quote Originally Posted by ganapathykumar
    for eg when i rclick this menu popups how should i write code for the menu item so that i can exit or do any action for the dialog ...
    You are passing the pWnd you get in OnContextMenu to the TrackPopupMenu - that's your dialog window, and that won't work: The command routing (as required for menu command handlers) needs a frame window, not a dialog box.
    Quote Originally Posted by ganapathykumar
    give me simple code to exit the dialog fro the context menu...
    Usually, dialog boxes are closed with the OK or Cancel buttons, or with the close button in the title bar.

  7. #7
    Join Date
    Feb 2005
    Posts
    29

    Re: iam not able to view the images in the tree

    so sir,

    how can i load a popup menu or a menu when a rclick inside
    a dialog box is there any other way 4 it

    plz help me...

    for eg,

    i rclick on a item in the tree in order to open the file

    how to do that.....

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