提交 | 用户 | age
|
0ed438
|
1 |
|
Q |
2 |
#include "pch.h"
|
|
3 |
#include "framework.h"
|
|
4 |
#include "ViewTree.h"
|
418cb3
|
5 |
#include "MTerm1.h"
|
0ed438
|
6 |
|
Q |
7 |
#ifdef _DEBUG
|
|
8 |
#define new DEBUG_NEW
|
|
9 |
#undef THIS_FILE
|
|
10 |
static char THIS_FILE[] = __FILE__;
|
|
11 |
#endif
|
|
12 |
|
|
13 |
/////////////////////////////////////////////////////////////////////////////
|
|
14 |
// CViewTree
|
|
15 |
|
|
16 |
CViewTree::CViewTree() noexcept
|
|
17 |
{
|
|
18 |
}
|
|
19 |
|
|
20 |
CViewTree::~CViewTree()
|
|
21 |
{
|
|
22 |
}
|
|
23 |
|
|
24 |
BEGIN_MESSAGE_MAP(CViewTree, CTreeCtrl)
|
418cb3
|
25 |
// ON_NOTIFY_REFLECT(NM_DBLCLK, &CViewTree::OnDblClkTree)
|
Q |
26 |
// ON_NOTIFY_REFLECT(NM_CLICK, &CViewTree::OnClkTree)
|
|
27 |
|
0ed438
|
28 |
END_MESSAGE_MAP()
|
Q |
29 |
|
|
30 |
/////////////////////////////////////////////////////////////////////////////
|
|
31 |
// CViewTree 消息处理程序
|
|
32 |
|
|
33 |
BOOL CViewTree::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
|
|
34 |
{
|
|
35 |
BOOL bRes = CTreeCtrl::OnNotify(wParam, lParam, pResult);
|
|
36 |
|
|
37 |
NMHDR* pNMHDR = (NMHDR*)lParam;
|
|
38 |
ASSERT(pNMHDR != nullptr);
|
|
39 |
|
|
40 |
if (pNMHDR && pNMHDR->code == TTN_SHOW && GetToolTips() != nullptr)
|
|
41 |
{
|
|
42 |
GetToolTips()->SetWindowPos(&wndTop, -1, -1, -1, -1, SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOSIZE);
|
|
43 |
}
|
|
44 |
|
|
45 |
return bRes;
|
|
46 |
}
|
418cb3
|
47 |
|
Q |
48 |
void CViewTree::OnClkTree(NMHDR* pNMHDR, LRESULT* pResult)
|
|
49 |
{
|
|
50 |
|
|
51 |
HTREEITEM hTreeItem = GetSelectedItem();
|
|
52 |
//以GetItemText()函数为例:
|
|
53 |
CString S1 = GetItemText(hTreeItem);
|
|
54 |
// AfxMessageBox(_T("You have selected ") + S1);
|
|
55 |
|
|
56 |
*pResult = 0;
|
|
57 |
|
|
58 |
}
|
|
59 |
|
|
60 |
void CViewTree::OnDblClkTree(NMHDR* pNMHDR, LRESULT* pResult)
|
|
61 |
{
|
|
62 |
LPNMTREEVIEW pNMTreeView = reinterpret_cast<LPNMTREEVIEW>(pNMHDR);
|
|
63 |
|
|
64 |
HTREEITEM hTreeItem = GetSelectedItem();
|
|
65 |
//以GetItemText()函数为例:
|
|
66 |
CString s2 = GetItemText(hTreeItem);
|
|
67 |
//AfxMessageBox(_T("You have selected ") + s1);
|
|
68 |
CString s1;
|
|
69 |
DWORD_PTR dw = GetItemData(hTreeItem);
|
|
70 |
s1.Format(_T("dbclk action %d, id %d oldid %d data %d x %d y %d text %s "),
|
|
71 |
pNMTreeView->action, hTreeItem, pNMTreeView->itemOld.hItem, dw, pNMTreeView->ptDrag.x, pNMTreeView->ptDrag.y,s2);
|
|
72 |
|
|
73 |
SysLog(s1);
|
|
74 |
|
|
75 |
*pResult = 0;
|
|
76 |
}
|