TreeListCtrl.cpp
资源名称:propgrid.zip [点击查看]
上传用户:yangzi5763
上传日期:2007-01-02
资源大小:239k
文件大小:4k
源码类别:
ActiveX/DCOM/ATL
开发平台:
Visual C++
- /************************************
- REVISION LOG ENTRY
- Revision By: Mihai Filimon
- Revised on 12/6/98 11:45:03
- Comments: TreeListCtrl.cpp : implementation file
- ************************************/
- #include "stdafx.h"
- #include "xpropertieswnd.h"
- #include "TreeListCtrl.h"
- #include "ControlsWnd.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CTreeListCtrl
- // Function name : CTreeListCtrl::CTreeListCtrl
- // Description : default constructor
- // Return type :
- CTreeListCtrl::CTreeListCtrl()
- {
- m_nColumnName = -1;
- m_nColumnValue = -1;
- m_nColumnGroup = -1;
- }
- // Function name : CTreeListCtrl::~CTreeListCtrl
- // Description : virtual destructor
- // Return type :
- CTreeListCtrl::~CTreeListCtrl()
- {
- }
- BEGIN_MESSAGE_MAP(CTreeListCtrl, CListCtrl)
- //{{AFX_MSG_MAP(CTreeListCtrl)
- // NOTE - the ClassWizard will add and remove mapping macros here.
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CTreeListCtrl message handlers
- // Function name : CTreeListCtrl::Init
- // Description : Called
- // Return type : void
- BOOL CTreeListCtrl::Init(CListCtrl* pParent)
- {
- if (Create(WS_CHILD, CRect(0,0,0,0), pParent, 0))
- {
- m_nColumnName = InsertColumn(0, _T("Name"));
- m_nColumnValue = InsertColumn(1, _T("Value"));
- m_nColumnGroup = InsertColumn(2, _T("Group"));
- return TRUE;
- }
- return FALSE;
- }
- // Function name : CTreeListCtrl::OnInsertItemVrt
- // Description :
- // Return type : int
- // Argument : int nItem
- // Argument : LPCTSTR lpszItemName
- // Argument : LPARAM lParam
- int CTreeListCtrl::OnInsertItemVrt(int nItem, LPCTSTR lpszItemName, LPARAM lParam, LPCTSTR lpszGroup)
- {
- int nResult = InsertItem(nItem, _T(""));
- if (nResult >= 0)
- {
- SetItemText(nResult, m_nColumnName, lpszItemName);
- SetItemText(nResult, m_nColumnGroup, lpszGroup);
- SetItemData(nResult, lParam);
- }
- return nResult;
- }
- // Function name : CTreeListCtrl::UpdateGroup
- // Description : Update array with all id of group lpszGroupName
- // Return type : void
- // Argument : CControlsWnd_CGroup* pGroup
- // Argument : LPCTSTR lpszGroupName
- void CTreeListCtrl::UpdateGroup(CControlsWnd_CGroup* pGroup, LPCTSTR lpszGroupName)
- {
- TArrayIDItem* pArray = pGroup->GetChilds();
- ASSERT (pArray);
- pArray->RemoveAll();
- int n = GetItemCount();
- for (int i = 0; i < n; i++)
- if (GetItemText(i, m_nColumnGroup).CompareNoCase(lpszGroupName) == 0)
- pArray->Add(i);
- }
- // Function name : CTreeListCtrl::GetName
- // Description : Return the name of item nItem
- // Return type : CString
- // Argument : int nItem
- CString CTreeListCtrl::GetName(int nItem)
- {
- return GetItemText(nItem, m_nColumnName);
- }
- // Function name : CTreeListCtrl::GetValue
- // Description : Return the value of item nItem
- // Return type : CString
- // Argument : int nItem
- CString CTreeListCtrl::GetValue(int nItem)
- {
- return GetItemText(nItem, m_nColumnValue);
- }
- // Function name : CTreeListCtrl::GetGroup
- // Description : Return the group name of nItem
- // Return type : CString
- // Argument : int nItem
- CString CTreeListCtrl::GetGroup(int nItem)
- {
- return GetItemText(nItem, m_nColumnGroup);
- }
- // Function name : CTreeListCtrl::GetUserData
- // Description : get the user data of item nItem
- // Return type : DWORD
- // Argument : int nItem
- DWORD CTreeListCtrl::GetUserData(int nItem)
- {
- return GetItemData(nItem);
- }
- // Function name : CTreeListCtrl::SetValue
- // Description : Save the value of this
- // Return type : CString
- // Argument : int nItem
- void CTreeListCtrl::SetValue(int nItem, LPCTSTR lpszValue)
- {
- SetItemText(nItem, m_nColumnValue, lpszValue);
- }