GME  13
MetaTreeCtrl.cpp
Go to the documentation of this file.
00001 // MetaTreeCtrl.cpp: implementation of the CMetaTreeCtrl class.
00002 //
00004 
00005 #include "stdafx.h"
00006 #include "gmeactivebrowser.h"
00007 #include "MetaTreeCtrl.h"
00008 
00009 #ifdef _DEBUG
00010 #undef THIS_FILE
00011 static char THIS_FILE[]=__FILE__;
00012 #define new DEBUG_NEW
00013 #endif
00014 
00016 // Construction/Destruction
00018 
00019 CMetaTreeCtrl::CMetaTreeCtrl()
00020 {
00021 
00022 }
00023 
00024 CMetaTreeCtrl::~CMetaTreeCtrl()
00025 {
00026 
00027 }
00028 
00029 // If recursive element returns NULL, otherwise the inserted item tree handle
00030 HTREEITEM CMetaTreeCtrl::InsertItem(HTREEITEM hParent, CString strObjectName, LPUNKNOWN pUnknown, objtype_enum otObjectType)
00031 {
00032         MGATREECTRL_LOGEVENT("CMetaTreeCtrl::InsertItem "+strObjectName+"\r\n");
00033 
00034         if(hParent==NULL)       // Root folder
00035         {
00036                 HTREEITEM hItem=CTreeCtrlEx::InsertItem(strObjectName,0,0,TVI_ROOT,TVI_SORT);   
00037                 CMgaObjectProxy ObjectProxy(pUnknown,otObjectType);
00038                 m_MgaMap.AddEntry(hItem,ObjectProxy);
00039                 SetItemData(hItem,(DWORD)0);
00040                 return hItem;
00041         }
00042 
00043         if(m_MgaMap.bIsInMap(pUnknown)) // If the element has been already insereted in the map
00044         {
00045                 HTREEITEM hItem=CTreeCtrlEx::InsertItem(strObjectName,(int)otObjectType,(int)otObjectType,hParent,TVI_SORT);    
00046                 HTREEITEM hRefItem;
00047                 m_MgaMap.LookupTreeItem(pUnknown,hRefItem); // Search for the handle of the inserted element
00048                 SetItemData(hItem,(DWORD)hRefItem); // Set item data to reference that
00049                 return NULL;
00050         }
00051         else
00052         {
00053                 HTREEITEM hItem=CTreeCtrlEx::InsertItem(strObjectName,(int)otObjectType,(int)otObjectType,hParent,TVI_SORT);    
00054                 CMgaObjectProxy ObjectProxy(pUnknown,otObjectType);
00055                 m_MgaMap.AddEntry(hItem,ObjectProxy);
00056                 SetItemData(hItem,(DWORD)0); // Set to zero if this is the first and hence no referenced element
00057                 return hItem;
00058         }
00059 }
00060 
00061