Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Some questions on CTreeCtrl

Status
Not open for further replies.

forlorn

Programmer
Dec 12, 2001
28
0
0
TR
Hi, i'm trying to writing a program to manage my mp3 collection. The interface is splitted in two parts and the left part contains a tree control where bands, albums and songs are shown.

Now i've a few questions :

1) I can add a right-click menu to entire tree but i want to add different menus to different items and i don't want any pop-up menu when right-clicked on an empty spot in the tree. I mean, when i click on a band item i want the "Add Album" menu, "Add Song" menu for an album item etc. How can i do that?

2) When i add new item, i want it to appear like in Windows Explorer when you add new folder. As the box appears with highlighted "New Folder" and it's ready for editing. How can i do that too?

Thanks in advance.

 
Your first question:

Use the tree control's SetItemData() and GetItemData() member functions to store and retrieve each node's type (i.e. Band = 1, Album = 2, Song = 3).

Then in your Right-Click handler, you can retrieve the type for the currently selected node, store the type in a member variable (to preserve it for later use) and build the custom menu you have defined for that type.

When you process the Right-Click menu item the user has selected, you'll know the type and the offset on the menu so you can do the correct action.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top