Introduction
Recently, I wanted to use a property table editor like VC7.0's. So, I searched it in CodeProject website. I found a good example in "CPropTree v1.0 - Property Tree Control", which is created by sramsay. Thanks to the author. I modified it a little, and added a toolbar, and a combobox, which made it like VC7.0's property table.
I added a new class, used for toolbar: CPropToolbar
, which is not created originally by me. I'm sorry I forget who created it originally.
And I added a new class: CToolbarContainer
, which is used to respond to the toolbar's commands.
Implementation
In PropToolbar.cpp, you need to add you toolbar's ID.
static const UINT toolbarItems[] =
{
ID_PROP_CATEGORIZE,
ID_PROP_ALPHABETIC
};
BEGIN_MESSAGE_MAP(CPropToolbar, CToolBarCtrl)
ON_NOTIFY_RANGE( TTN_NEEDTEXTA, ID_PROP_CATEGORIZE,
ID_PROP_ALPHABETIC, OnNeedTextA)
ON_NOTIFY_RANGE( TTN_NEEDTEXTW, ID_PROP_CATEGORIZE,
ID_PROP_ALPHABETIC, OnNeedTextW)
ON_WM_LBUTTONDBLCLK()
END_MESSAGE_MAP()
In ToolbarContainer.h, I added a message map to deal with the toolbar's commands.
afx_msg void OnSortByCategory();
afx_msg void OnSortByAlpha();
You can get the detailed implementation in my source code. Maybe my code is short of comments, but tidy enough :(, you can get it.
A Big Interesting Bug
Yell, after I implemented it, I was happy it looked very well. But soon, I found a big bug. Sometimes when you are operating it, or when you minimize it, wait for some time (maybe half an hour), you will find the toolbar changed as before.
I don't know what causes that. Maybe someone can tell me or solve it. I will really appreciate him/her very much! Can you?