我现在做一个tree类似于vc左侧的FileView,包含文件夹和文件夹里的文件
现在我的代码:
//图标位图
pTreeImageList = new CImageList();
pTreeImageList->Create(IDB_BITMAP1, 16, 0, RGB (255, 0, 0));
m_TreeCtrl.SetImageList ( pTreeImageList, TVSIL_NORMAL );
//插入item,其中第二个参数0是文件夹关闭状态,第三个参数1是文件夹打开状态
InsertItem( ItemName, 0, 1, 0 );
这样当鼠标选择文件夹时是文件夹打开状态,选择其他文件夹或文件时,前面的文件夹是关闭状态,这样只有一个文件夹是打开的状态。
现在我想当无论我选择文件或文件夹时,上级文件夹依然保持打开状态,只有双击或点击加号时,文件夹关闭。如果我说的不够明白,大家可以看看VC的FileView,我就是想做个那样的tree.
现在我想用SetItemImage来实现,应该怎么做,或者有什么其他的更好的办法?
现在我的代码:
//图标位图
pTreeImageList = new CImageList();
pTreeImageList->Create(IDB_BITMAP1, 16, 0, RGB (255, 0, 0));
m_TreeCtrl.SetImageList ( pTreeImageList, TVSIL_NORMAL );
//插入item,其中第二个参数0是文件夹关闭状态,第三个参数1是文件夹打开状态
InsertItem( ItemName, 0, 1, 0 );
这样当鼠标选择文件夹时是文件夹打开状态,选择其他文件夹或文件时,前面的文件夹是关闭状态,这样只有一个文件夹是打开的状态。
现在我想当无论我选择文件或文件夹时,上级文件夹依然保持打开状态,只有双击或点击加号时,文件夹关闭。如果我说的不够明白,大家可以看看VC的FileView,我就是想做个那样的tree.
现在我想用SetItemImage来实现,应该怎么做,或者有什么其他的更好的办法?
-------------------------------------HTREEITEM HitTest(
CPoint pt,
UINT* pFlags = NULL
) const;pt
Client coordinates of the point to test. flags
Variable that receives information about the results of a hit test. This member can be one or more of the following values: TVHT_ABOVE
Above the client area.
TVHT_BELOW
Below the client area.
TVHT_NOWHERE
In the client area, but below the last item.
TVHT_ONITEM
On the bitmap or label associated with an item.
TVHT_ONITEMBUTTON
On the button associated with an item.
TVHT_ONITEMICON
On the bitmap associated with an item.
TVHT_ONITEMINDENT
In the indentation associated with an item.
TVHT_ONITEMLABEL
On the label (string) associated with an item.
TVHT_ONITEMRIGHT
In the area to the right of an item.
TVHT_ONITEMSTATEICON
On the state icon for a tree-view item that is in a user-defined state.
TVHT_TOLEFT
To the left of the client area.
TVHT_TORIGHT
To the right of the client area.
{
// Expanded
}
else
{
// Not expand
}
函数形式是用这个吗?
HTREEITEM HitTest( TVHITTESTINFO* pHitTestInfo );
我原来是用HTREEITEM hItem =HitTest(point);
现在基本问题已经解决了,只是点文件夹和+号有时会产生冲突