Proper way to get item from CTreeCtrl

Posted on 1999-12-23
Medium Priority
Last Modified: 2013-11-20
  I have added items to a tree control. i record their identities by giving each one a special lParam. given this, how can i use "GetItem" to return the hItem, so I can delete it?

Question by:pipe
  • 2
LVL 11

Accepted Solution

mikeblas earned 300 total points
ID: 2304800
You can't do that: the tree control simply doesn't work that way.  GetItem() gets an item based on the hItem; it doesn't find an item matching the attributes you want to specify.

If you wanted, I guess you could write some recursive code to get each item using GetNextItem() and examine the lParam of every item in the control. But that would be terrible: performance would be miserable.

Instead, I think you should record their identities by building a list or array of the hItems you get back.  What's the "special value" you're storing?

..B ekiM

Author Comment

ID: 2305520
yea, i fixed it. lot of work tho
LVL 11

Expert Comment

ID: 2305878
> lot of work tho

Work is what you get paid for.

..B ekiM

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
How can you see what you are working on when you want to see it while you to save a copy? Add a "Save As" icon to the Quick Access Toolbar, or QAT. That way, when you save a copy of a query, form, report, or other object you are modifying, you…
Suggested Courses

589 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question