Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

[040794]: MyTreeCtrl.h Maximize Restore History

Download this file

MyTreeCtrl.h    74 lines (59 with data), 2.1 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
* Silly subclass of CTreeCtrl just to implement Drag&Drop.
*
* Based on MFC sample code from CMNCTRL1
*/
#ifndef _MYTREECTRL_H
#define _MYTREECTRL_H
#include <Afxcmn.h>
class CMyTreeCtrl : public CTreeCtrl
{
public:
CMyTreeCtrl();
~CMyTreeCtrl();
enum {NODE=0, LEAF=1, EXPIRED_LEAF = 2}; // indices of bitmaps in ImageList
void DeleteWithParents(HTREEITEM hItem); // if a parent node becomes a leaf
CString GetGroup(HTREEITEM hItem); // get group path to hItem
HTREEITEM AddGroup(const CString &path);
bool IsLeafNode(HTREEITEM hItem);
void RestoreExpanded();
void ClearExpanded(); // use when items will be invalid
void OnCollapseAll();
void OnExpandAll();
void SetDboxPointer(void *parent) {m_parent = parent;}
protected:
//{{AFX_MSG(CMyTreeCtrl)
afx_msg void OnBeginLabelEdit(LPNMHDR pnmhdr, LRESULT *pLResult);
afx_msg void OnEndLabelEdit(LPNMHDR pnmhdr, LRESULT *pLResult);
afx_msg void OnExpandCollapse(NMHDR *pNotifyStruct, LRESULT *result);
afx_msg void OnBeginDrag(LPNMHDR pnmhdr, LRESULT *pLResult);
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
afx_msg void OnDestroy();
afx_msg void OnTimer(UINT nIDEvent);
//
//afx_msg void OnSelchanged(NMHDR* pNMHDR, LRESULT* pResult);
//}}AFX_MSG
void EndDragging(BOOL bCancel);
BOOL PreTranslateMessage(MSG* pMsg);
DECLARE_MESSAGE_MAP()
private:
bool m_bDragging;
HTREEITEM m_hitemDrag;
HTREEITEM m_hitemDrop;
CImageList *m_pimagelist;
void *m_parent;
void *m_expandedItems; // Internally this is a SetTreeItem_t, don't want to include stl file here...
bool m_isRestoring; // don't repopulate m_expandedItems in restore
void SetNewStyle(long lStyleMask, BOOL bSetBits);
bool TransferItem(HTREEITEM hitem, HTREEITEM hNewParent);
void OnButtonUp(void);
bool IsChildNodeOf(HTREEITEM hitemChild, HTREEITEM hitemSuspectedParent);
void UpdateLeafsGroup(HTREEITEM hItem, CString prefix);
protected:
UINT m_nTimerID;
UINT m_timerticks;
UINT m_nHoverTimerID;
POINT m_HoverPoint;
};
#endif /* _MYTREECTRL_H */