void CreateToolbars() { if (Glb_toolbarArray.GetCount() > 0) return; IAcadMenuGroup *mnuGrp = NULL; if (!getAcadMenuGroup(&mnuGrp)) return ; IAcadToolbars *tlbrs = NULL; HRESULT hr = S_OK; hr = mnuGrp->get_Toolbars(&tlbrs); mnuGrp->Release(); // 得到arx所在路径 TCHAR lpPath[MAX_PATH] = {0}; GetModuleFileName(GetModuleHandle("DistToolBar.arx"), lpPath, MAX_PATH); PathRemoveFileSpec(lpPath); PathAddBackslash(lpPath); CString strXmlFile = lpPath; strXmlFile += "toolbar.xml"; // 得到icon路径 PathAppend(lpPath, "icon"); PathAddBackslash(lpPath); MSXML2::IXMLDOMDocumentPtr lpDocument; hr = lpDocument.CreateInstance(__uuidof(DOMDocument)); if ( FAILED(hr) ) _com_raise_error(hr); VARIANT_BOOL isSuccessful; // 装载XML字符串 if (!lpDocument->load(_variant_t(strXmlFile))) { OutputDebugString("LoadXML failed!"); return; } MSXML2::IXMLDOMElementPtr lpDocElement = NULL; lpDocument->get_documentElement(&lpDocElement); // toolbar list MSXML2::IXMLDOMNodeListPtr lpToolbarList = lpDocElement->getElementsByTagName(_bstr_t("toolbar")); MSXML2::IXMLDOMNodePtr lpToolbar = NULL; for ( ; (lpToolbar = lpToolbarList->nextNode()) != NULL ; ) { MSXML2::IXMLDOMNodePtr lpCaptionNode = lpToolbar->attributes->getNamedItem("caption"); CString strCaption = (char*)lpCaptionNode->text; OutputDebugString(strCaption); // 添加工具条 IAcadToolbar *tlbr = NULL; hr = tlbrs->Add(CComBSTR(strCaption), &tlbr); if FAILED(hr) continue; Glb_toolbarArray.Add(strCaption); // button list MSXML2::IXMLDOMNodeListPtr lpButtonList = lpToolbar->GetchildNodes(); MSXML2::IXMLDOMNodePtr lpButton = NULL; for ( ; (lpButton = lpButtonList->nextNode()) != NULL ; ) { MSXML2::IXMLDOMNodePtr lpToolTipNode = lpButton->attributes->getNamedItem("tooltip"); CString strToolTip = (char*)lpToolTipNode->text; MSXML2::IXMLDOMNodePtr lpCommandNode = lpButton->attributes->getNamedItem("command"); CString strCommand = (char*)lpCommandNode->text; strCommand += " "; MSXML2::IXMLDOMNodePtr lpIconNode = lpButton->attributes->getNamedItem("icon"); CString strIcon = (char*)lpIconNode->text; OutputDebugStringX("tooltip=%s, command=%s, icon=%s", strToolTip, strCommand, strIcon); // 添加工具按钮 IAcadToolbarItem *button=NULL; VARIANT index; index.vt = VT_I4; index.lVal = 100l; VARIANT vtFalse; vtFalse.vt = VT_BOOL; vtFalse.boolVal = VARIANT_FALSE; CString strIconFile = lpPath; strIconFile += strIcon; if (!PathFileExists(strIconFile)) { strIconFile = lpPath; strIconFile += "dist.ico"; } if (!PathFileExists(strIconFile)) continue; hr = tlbr->AddToolbarButton(index, CComBSTR(strToolTip), CComBSTR(strToolTip), CComBSTR(strCommand), vtFalse, &button); hr = button->SetBitmaps(CComBSTR(strIconFile), CComBSTR(strIconFile)); button->Release(); } tlbr->Dock(acToolbarDockRight);//acToolbarFloating tlbr->Release(); } tlbrs->Release(); return; }
int CSOAPUtil::ParseSOAPRequest(char* xml, int xmlSize, SOAP_REQUEST_INFO* info) { int res = NO_ERR; MSXML2::IXMLDOMDocumentPtr xmlDoc; HRESULT hr = xmlDoc.CreateInstance(MSXML2::CLSID_DOMDocument); if(FAILED(hr)) { return ERR_FALSE; } xmlDoc->put_async(VARIANT_FALSE); xmlDoc->put_preserveWhiteSpace(VARIANT_TRUE); if( LoadDOMDocument(xml, xmlSize, xmlDoc) != NO_ERR ) { xmlDoc.Release(); xmlDoc = NULL; return ERR_FALSE; } //��� MSXML2::IXMLDOMElementPtr pElemRoot; MSXML2::IXMLDOMNodePtr mediaNode = NULL; xmlDoc->get_documentElement(&pElemRoot); if( pElemRoot == NULL ) { res = ERR_FALSE; goto Err_End; } for( int i=0; i<pElemRoot->childNodes->length; i++ ) { MSXML2::IXMLDOMNodePtr bodyNode = pElemRoot->childNodes->Getitem(i); CComBSTR localName; bodyNode->get_baseName(&localName); if( localName == NULL ) { continue; } if(CompareNoCase(L"Body", localName.m_str) == 0 ) { for( int j=0; j<bodyNode->childNodes->length; j++ ) { MSXML2::IXMLDOMNodePtr actionNode = bodyNode->childNodes->Getitem(j); CComBSTR actionName; actionNode->get_baseName(&actionName); if( actionName == NULL ) { continue; } info->actionName = actionName; for( int k=0; k<actionNode->childNodes->length; k++) { MSXML2::IXMLDOMNodePtr argNode = actionNode->childNodes->Getitem(k); CComBSTR argName; argNode->get_baseName(&argName); if( argName == NULL ) { continue; } CComBSTR argVal; argNode->get_text(&argVal); info->argList.insert(pair<wstring,wstring>(argName.m_str, argVal.m_str)); } } break; } } Err_End: xmlDoc.Release(); xmlDoc = NULL; return res; }