Advertisement Jump to content


This topic is now archived and is closed to further replies.


Help - Tree Control Problems(MFC)

This topic is 5354 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

This is my first time using a TreeControl, and I''m having trouble getting my tree control to display anything. I''ve got a MFC MDI project in which I''ve created a dockable DialogBar. On this dialog (COrganizerBar), I placed a Tree control resourc, and assigned it a resource ID (IDR_ORGANIZER_TREE). I then went into the class wizard and added a member variable (m_tree) that is linked to IDR_ORGANIZER_TREE.. Finally I went into COrganizerBar::OnCreate(), and added the following code:
int COrgaizerBar::OnCreate(LPCREATESTRUCT lpCreateStruct)
     if(CDialog::OnCreate(lpCreateStruct) == -1)
          return -1;

     HTREEITEM hProject = m_tree.InsertItem("Project", TVI_ROOT);
     HTREEITEM hChild = m_tree.InsertItem("Child Item", hProject,TVI_LAST);

     m_tree.UpdateData(); // Don''t know if I need this.. so far hasn''t made a difference

Anyway, the dialog bar appears, and docks, and even shows the "tree area" as designated by a white rectangle in the dialog, but none of my tree data is visible. Any MFC gurus out there have a suggestion for me?

Share this post

Link to post
Share on other sites
Guest Anonymous Poster
Try putting

m_tree.SubclassDlgItem(IDR_ORGANIZER_TREE, this);

at the beginning of OnCreate. For some reason CDialogBars and CDialog work slightly differently when it comes to Dialog Data Exchange (DDX). I''ve found this works for me with CDialogBars. You may also want to remove any IDR_ORGANIZER_TREE related DDX... lines added by the class wizard in the DoDataExchange code .

Hope this helps

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!