提交 | 用户 | age
|
65f713
|
1 |
|
Q |
2 |
#include "pch.h"
|
|
3 |
#include "framework.h"
|
|
4 |
#include "ViewTree.h"
|
|
5 |
#include "MTerm2.h"
|
|
6 |
|
|
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)
|
|
25 |
ON_NOTIFY_REFLECT(NM_DBLCLK, &CViewTree::OnDblClkTree)
|
|
26 |
ON_NOTIFY_REFLECT(NM_CLICK, &CViewTree::OnClkTree)
|
|
27 |
|
|
28 |
END_MESSAGE_MAP()
|
|
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 |
}
|
|
47 |
|
|
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 |
s1.Format(_T("dbclk Code %d, id %d %d %d %s "), pNMTreeView->action,pNMTreeView->itemOld.hItem, pNMTreeView->ptDrag.x, pNMTreeView->ptDrag.y,s2); |
|
70 |
|
|
71 |
SysLog(s1); |
|
72 |
|
|
73 |
*pResult = 0; |
|
74 |
} |