囧,实在是囧啊。比起ListView,TreeView还真是简单了无穷多倍,一个晚上就搞定了。贴贴代码和图。
1 /*********************************************************************************************************
2 Tree View
3 *********************************************************************************************************/
4
5 class VL_WinTreeViewItem : public VL_Base
6 {
7 friend class VL_WinTreeView;
8 protected:
9 HWND FHandle;
10 HTREEITEM FItem;
11
12 VL_WinTreeViewItem(HWND Handle , HTREEITEM Item);
13 public:
14 VL_WinTreeViewItem(const VL_WinTreeViewItem& Item);
15 VL_WinTreeViewItem();
16 VL_WinTreeViewItem& operator=(const VL_WinTreeViewItem& Item);
17 operator VBool();
18
19 VL_WinTreeViewItem InsertAtLast(VUnicodeString Text , VInt ImageIndex=-1 , VInt SelectedImageIndex=-1);
20 VL_WinTreeViewItem InsertAtFirst(VUnicodeString Text , VInt ImageIndex=-1 , VInt SelectedImageIndex=-1);
21 VL_WinTreeViewItem InsertAfter(VUnicodeString Text , VInt ImageIndex=-1 , VInt SelectedImageIndex=-1);
22 void DeleteSelf();
23
24 VL_WinTreeViewItem GetParent();
25 VL_WinTreeViewItem GetFirstChild();
26 VL_WinTreeViewItem GetPrevious();
27 VL_WinTreeViewItem GetNext();
28 VL_WinTreeViewItem GetNextVisible();
29 VL_WinTreeViewItem GetPrevVisible();
30 VL_WinTreeViewItem GetNextSelected();
31
32 void SetDropTarget();
33 void SetFirstVisible();
34
35 VUnicodeString GetText();
36 void SetText(VUnicodeString Value);
37
38 VInt GetImageIndex();
39 void SetImageIndex(VInt Value);
40
41 VInt GetSelectedImageIndex();
42 void SetSelectedImageIndex(VInt Value);
43
44 VPointer GetCustomData();
45 void SetCustomData(VPointer Value);
46
47 VBool GetBoldState();
48 void SetBoldState(VBool Value);
49
50 VBool GetCutState();
51 void SetCutState(VBool Value);
52
53 VBool GetDropHilitedState();
54 void SetDropHilitedState(VBool Value);
55
56 VBool GetExpendedState();
57 void SetExpendedState(VBool Value);
58
59 VBool GetSelectedState();
60 void SetSelectedState(VBool Value);
61
62 VBool GetChecked();
63 void SetChecked(VBool Value);
64
65 void EnsureVisible();
66 void Expand();
67 void Collapse();
68 void Toggle();
69 };
70
71 VL_DEFINE_VOID_EVENT (VE_TreeViewItemEvent ,(Sender , Item) ,(VL_Base* Sender , VL_WinTreeViewItem Item));
72 VL_DEFINE_VOID_EVENT (VE_TreeViewVerifyEvent ,(Sender , Item , Accept) ,(VL_Base* Sender , VL_WinTreeViewItem Item , VBool& Accept));
73 VL_DEFINE_VOID_EVENT (VE_TreeViewEditEvent ,(Sender , Item , Accept , Text) ,(VL_Base* Sender , VL_WinTreeViewItem Item , VBool& Accept , VUnicodeString Text));
74
75 class VL_WinTreeView : public VL_WinControl
76 {
77 protected:
78 VL_WinImageList* FNormalImageList;
79 VL_WinImageList* FStateImageList;
80 public:
81 VL_WinTreeView(VL_WinContainer* Parent);
82 ~VL_WinTreeView();
83 LRESULT ProcessMessage(UINT Message , WPARAM& wParam , LPARAM& lParam , VBool& CallDefaultProcedure);
84
85 VE_NotifyEvent OnClick;
86 VE_NotifyEvent OnDbClick;
87 VE_NotifyEvent OnRightClick;
88 VE_NotifyEvent OnRightDbClick;
89 VE_TreeViewItemEvent OnBeginDrag;
90 VE_TreeViewItemEvent OnBeginRightDrag;
91 VE_TreeViewEditEvent OnBeginLabelEdit;
92 VE_TreeViewEditEvent OnEndLabelEdit;
93 VE_TreeViewItemEvent OnItemExpanding;
94 VE_TreeViewItemEvent OnItemExpanded;
95 VE_TreeViewVerifyEvent OnItemSelecting;
96 VE_TreeViewItemEvent OnItemSelected;
97
98 VL_WinImageList* GetNormalImageList();
99 void SetNormalImageList(VL_WinImageList* ImageList);
100
101 VL_WinImageList* GetStateImageList();
102 void SetStateImageList(VL_WinImageList* ImageList);
103
104 COLORREF GetLineColor();
105 void SetLineColor(COLORREF Value);
106
107 COLORREF GetTextColor();
108 void SetTextColor(COLORREF Value);
109
110 COLORREF GetBackColor();
111 void SetBackColor(COLORREF Value);
112
113 /**********************************************************
114 Styles
115 **********************************************************/
116
117 VBool GetShowCheckBoxes();
118 void SetShowCheckBoxes(VBool Value);
119
120 VBool GetEnableDragDrop();
121 void SetEnableDragDrop(VBool Value);
122
123 VBool GetEditable();
124 void SetEditable(VBool Value);
125
126 VBool GetFullRowSelect();
127 void SetFullRowSelect(VBool Value);
128
129 VBool GetHasButtons();
130 void SetHasButtons(VBool Value);
131
132 VBool GetHasLines();
133 void SetHasLines(VBool Value);
134
135 VBool GetAlwaysShowSelection();
136 void SetAlwaysShowSelection(VBool Value);
137
138 VBool GetDimmedCheckBoxes();
139 void SetDimmedCheckBoxes(VBool Value);
140
141 VBool GetExclusionCheckBoxes();
142 void SetExclusionCheckBoxes(VBool Value);
143
144 VBool GetFadeButton();
145 void SetFadeButton(VBool Value);
146
147 /**********************************************************
148 Actions
149 **********************************************************/
150
151 void EditLabel(VL_WinTreeViewItem Item);
152 void FinishEditLabel();
153 void CancelEditLabel();
154
155 /**********************************************************
156 Items
157 **********************************************************/
158
159 VL_WinTreeViewItem AddRootItem(VUnicodeString Text , VInt ImageIndex=-1 , VInt SelectedImageIndex=-1);
160 VL_WinTreeViewItem GetFirstRoot();
161 VL_WinTreeViewItem GetCurrentSelectedItem();
162 VL_WinTreeViewItem GetFirstVisible();
163 VL_WinTreeViewItem GetLastVisible();
164 VL_WinTreeViewItem GetDropHighlighted();
165 void Clear();
166 };
posted on 2008-08-11 05:05
陈梓瀚(vczh) 阅读(2284)
评论(6) 编辑 收藏 引用 所属分类:
C++