📄 ztreecontrol.h
字号:
#pragma once
#include "zcontrol.h"
#include "zFile.h"
#include "zGraphList.h"
#include "zTreeNode.h"
#include "zTreeFlags.h"
class zTreeControl : public zControl
{
public:
zTreeControl(void);
~zTreeControl(void);
virtual int CreateEx(int ctlid,int x, int y, int nWidth, int nHeight, HWND hParent,HINSTANCE hInst);
virtual int OnNotify(LPNMHDR lParam);
virtual void OnCustomDraw(LPNMTVCUSTOMDRAW lParam);
virtual int OnDispInfo(LPNMHDR lParam);
virtual void OnClick(zTreeNode * pNode);
virtual void OnDblclk(zTreeNode * pNode);
//对树结构进行存储
zTreeFlags m_Flag;
private:
zFile * m_pFile;
public:
void SetFile(zFile * pFile){m_pFile = pFile;};
zFile * GetFile(){return m_pFile;};
int Save(TCHAR * pszSaveName); //保存
int SaveItem(HTREEITEM hti); //遍历项
virtual int SaveNode(zTreeNode *pNode); //保存节点内容,派生类需要重载
int Load(TCHAR * pszLoadName); //读取
int LoadItem(zTreeNode * pNode); //遍历项
virtual int LoadNode(zTreeNode * pNode); //读取节点内容,派生类需要重载
//对节点进行操作
private:
zTreeNode * m_pNode; //当前结点位置
public:
int Reset(); //复位
int Delete(); //删除一个节点
int AddRoot(zTreeNode * pNode); //增加一个Root
int AddChild(zTreeNode * pNode ,HTREEITEM flag=TVI_LAST); //增加一个子结点 flag =(TVI_FIRST/TVI_LAST/TVI_SORT)
int AddSibling(zTreeNode * pNode,HTREEITEM flag=TVI_LAST); //增加一个兄弟结点
int FlushText(zTreeNode * pNode);
int AddParentNum(zTreeNode * pNode);
int DeleteParentNum(zTreeNode * pNode);
zTreeNode * GetCurrent();
zTreeNode * GetNodeParam(HTREEITEM hti);
int SetCurrent(NM_TREEVIEW* pLvdi);
int SetCurrent(zTreeNode * pNode);
void MoveFirst(); //将当前项移到父项的第一个
void MovePrev(); //将当前项前移一位
void MoveNext(); //将当前项后移一位
void MoveLast(); //将当前项移到父项的最后
void MoveUp(); //将当前项升级成为父项的兄弟项,各子项同时升级
void MoveDown(); //将当前项降级,成为上一项的子项
int GotoRoot(); //当前选择项设定到根项
int GotoParent(); //当前选择项设定到父项
int GotoChild(); //当前选择项设定到子项
int GotoPrevSibling(); //当前选择项设定到兄弟前项
int GotoNextSibling(); //当前选择项设定到兄弟后项
void ExpandRoot();
int Foreach(zTreeNode * pCurrent = NULL,int nWorkType=0);
void bl(HTREEITEM hti,int nWorkType);
virtual void deal(zTreeNode * pNode,int nWorkType); //对每个节点进行处理
void FlushDiskTree(TCHAR * pPath = _T(""));
private:
void blDiskTree(TCHAR * pPath);
// void SortByName(zTreeNode * p1,zTreeNode * p2);
// BOOL zTreeControl:: SortByName(zTreeControl::zTreeNode * p1,zTreeControl::zTreeNode * p2);
//对菜单的操作
virtual int OnPopupMenu(POINT point);
//对图标的操作
private:
zGraphList * m_pImageList;
zGraphList * m_pImageSave;
public:
void SetImageList(zGraphList * pList)
{
if (!m_hCtrl) return;
if (pList)
{
m_pImageList = pList;
m_pImageSave = pList;
TreeView_SetImageList(m_hCtrl,m_pImageList->m_hList,TVSIL_NORMAL);
}else
{
m_pImageList = NULL;
TreeView_SetImageList(m_hCtrl,NULL,TVSIL_NORMAL);
}
}
//对状态的操作,用户自绘制(未完成)
private:
};
/* 以下宏是WINCE支持的,其他因为PPC不支持,未列出,也未使用
TreeView_CreateDragItem //
TreeView_DeleteAllItem //删除所有项
TreeView_DeleteItem //删除一项.
TreeView_EditLabel //编辑一项
TreeView_EndEditLabelNow //结束编辑
TreeView_EnsureVisible //使某一项可见
TreeView_Expand //展开
TreeView_GetChild //获取指定项的第一个子项
TreeView_GetCount //获取控件项数
TreeView_GetDropHilight //
TreeView_GetEditControl //获取编辑控件句柄
TreeView_GetFirstVisible //获取在控件窗口中第一个可见项
TreeView_GetImageList //获取图形列表控件句柄
TreeView_GetIndent //获取排列像素大小
TreeView_GetlSearchString //查找字符串
TreeView_GetItem //获取某项属性
TreeView_GetItemRect //获取某项rect
TreeView_GetNextItem //获取下一项
// TVGN_CARET Retrieves the currently selected item. You can use the TreeView_GetSelection macro to send this message.
// TVGN_CHILD Retrieves the first child item of the item specified by the hitem parameter. You can use the TreeView_GetChild macro to send this message.
// TVGN_DROPHILITE Retrieves the item that is the target of a drag-and-drop operation. You can use the TreeView_GetDropHilight macro to send this message.
// TVGN_FIRSTVISIBLE Retrieves the first visible item. You can use the TreeView_GetFirstVisible macro to send this message.
// TVGN_NEXT Retrieves the next sibling item. You can use the TreeView_GetNextSibling macro to send this message.
// TVGN_NEXTVISIBLE Retrieves the next visible item that follows the specified item. The specified item must be visible. Use the TVM_GETITEMRECT message to determine whether an item is visible. You can use the TreeView_GetNextVisible macro to send this message.
// TVGN_PARENT Retrieves the parent of the specified item. You can use the TreeView_GetParent macro to send this message.
// TVGN_PREVIOUS Retrieves the previous sibling item. You can use the TreeView_GetPrevSibling macro to send this message.
// TVGN_PREVIOUSVISIBLE Retrieves the first visible item that precedes the specified item. The specified item must be visible. Use the TVM_GETITEMRECT message to determine whether an item is visible. You can use the TreeView_GetPrevVisible macro to send this message.
// TVGN_ROOT
TreeView_GetNextSibling //获取下一个兄弟项
TreeView_GetNextVisible //获取下一个可见项
TreeView_GetParent //获取当前项的父项
TreeView_GetPrevSibling //获取前一个兄弟项
TreeView_GetPrevVisible //获取前一个可见项
TreeView_GetRoot //获取根项
TreeView_GetSelection //获取选择项
TreeView_GetVisibleCount //获取在控件中显示的项数
TreeView_HitTest //获取鼠标点位置测试.
TreeView_InsertItem //
TreeView_Select //
TreeView_SelectDropTarget //
TreeView_SelectItem //
TreeView_SelectSetFirstVisible //
TreeView_SetImageList //
TreeView_SetIndent //
TreeView_SetItem //
TreeView_SortChildren //
TreeView_SortChildrenCB //
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -