Months ago, I needed a tree editor that could be used conveniently, and I couldn't find any in the Internet, so I did it by myself. I got some code from the article "Tree Editor" by Yossi Patt. Thanks very much!
I added a new class, used for the toolbar to operate the tree editor:
CToolbarEx, which is not created originally by me. I'm sorry I forget who created it originally. And I just added some new functions which are used to respond to the toolbar's commands.
In ToolbarEx.cpp, you need to add you toolbar's ID.
static const UINT toolbarItems =
ON_NOTIFY_RANGE( TTN_NEEDTEXTA, ID_LEFT_ITEM, ID_DOWN_ITEM, OnNeedTextA)
ON_NOTIFY_RANGE( TTN_NEEDTEXTW, ID_LEFT_ITEM, ID_DOWN_ITEM, OnNeedTextW)
OnNeedTextA respond to non-Unicode, and
OnNeedTextW to Unicode. Of course, you can combine them to one function. The work is left to those who are interested in UNICODE.
CTreeEditor class, I added a message map to deal with the toolbar's commands:
I think you can get the detailed implementation from my source code. Maybe my code is short of comments, but tidy enough so you can get it.
A Big Bug
Yell, as in my last article "A Property Table Editor", I found the same big bug. Sometimes when you are operating it, or when you minimize it, and then wait for some time (maybe half an hour), you will find that the toolbar has changed as the second picture shows, to be wider.
I don't know what causes that. Maybe someone can tell me or solve it. I will really appreciate him/her very much! You can have a try!