ParameterBlock &ParameterBlock::operator=(const ParameterBlock &other) { IXMLDOMElement *e = other.e_; if (e_ == e) { return *this; } if (e != NULL) { e->AddRef(); } if (e_ != NULL) { e_->Release(); } e_ = e; return *this; }
HRESULT CPageEvents::AddXMLNodeToTree(IXMLDOMNode* pNode, HTREEITEM hParent) { // Get the list of child nodes IXMLDOMNodeListPtr spChildren; RETURN_FAILED(pNode->get_childNodes(&spChildren)); // Process each child node IXMLDOMNodePtr spChild; do { // Get the next node of the child list RETURN_FAILED(spChildren->nextNode(&spChild)); if (NULL != spChild) { // Get the child node's tagname int iImage; CString strType; CString strID; bool bIsGroup, bIsEvent; CComBSTR bstrText; IXMLDOMElementPtr spElement(spChild); if (NULL != spElement) { CComBSTR bstrTagName; RETURN_FAILED(spElement->get_tagName(&bstrTagName)); if (bstrTagName.Length()) { // Accept the Event and EventGroup tag names if (0 == wcscmp(bstrTagName, m_bstrEvent)) { bIsGroup = false; bIsEvent = true; } else if (0 == wcscmp(bstrTagName, m_bstrEventGroup)) { bIsGroup = true; bIsEvent = false; } // Get the display attributes if this is a group or event node if (bIsGroup || bIsEvent) { // Get the type of the element CComBSTR bstrSeverity; GetElementSeverity(spElement, &bstrSeverity); iImage = ImageFromSeverity(bstrSeverity); strType = TypeFromSeverity(bstrSeverity); // Get the id of the element CComBSTR bstrID; GetElementID(spElement, &bstrID); strID = bstrID; // Get the name of the element RETURN_FAILED(GetElementDisplayName(spElement, &bstrText)); } } } // Add the node to the tree and list controls if (bstrText.Length()) { // Typecast the element pointer as an LPARAM IXMLDOMElement* pElement = spElement.Detach(); LPARAM lParam = reinterpret_cast<LPARAM>(pElement); // Insert the element into the tree USES_CONVERSION; LPCTSTR pszText = OLE2CT(bstrText); UINT mask = TVIF_PARAM | TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE; HTREEITEM hItem = m_tree.InsertItem(mask, pszText, iImage, iImage, 0, 0, lParam, hParent, TVI_LAST); // Insert the element into the list, if its not an <EventGroup> if (!bIsGroup) { int iItem = m_listEvents.GetItemCount(); iItem = m_listEvents.InsertItem(LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM, iItem, strType, 0, 0, iImage, lParam); if (-1 != iItem) { // Keep a reference on the element pointer in the LPARAM pElement->AddRef(); // Keep track of maximum widths int cx = m_listEvents.GetStringWidth(strType + " "); m_cxMaxType = max(m_cxMaxType, cx); cx = m_listEvents.GetStringWidth(strID + " "); m_cxMaxID = max(m_cxMaxID, cx); // Set the subitems m_listEvents.SetItem(iItem, 1, LVIF_TEXT, strID, 0, 0, 0, 0); m_listEvents.SetItem(iItem, 2, LVIF_TEXT, pszText, 0, 0, 0, 0); } } // Recurse into node, if it's a group if (bIsGroup) { RETURN_FAILED(AddXMLNodeToTree(spChild, hItem)); } } } } while (NULL != spChild); // Indicate success return S_OK; }