inline int basic_dbgstreambuf<elem_t, traits_t>::sync() { if (ppos() == 0) //avoid unnecessary carriage return in dbgview return 0; *pptr() = elem_t(); OutputDebugStringX(pbase()); ppos(0); return 0; }
inline typename basic_dbgstreambuf<elem_t, traits_t>::int_type basic_dbgstreambuf<elem_t, traits_t>::overflow(int_type c_) { if (traits_t::eq_int_type(traits_t::eof(), c_)) return traits_t::eof(); const elem_t c = traits_t::to_char_type(c_); //sync(); //NOTE: No, we can't do this here, since dbgview will //break the text across lines when the auto-scroll //option is enabled. const ptrdiff_t oldlen = epptr() - pbase(); const ptrdiff_t newlen = oldlen ? 2 * oldlen : 1; if (elem_t* const newbuf = new (std::nothrow) elem_t[newlen + 1]) { const std::streamsize pos = ppos(); #if _MSC_VER >= 1400 const size_t size_in_bytes = newlen * sizeof(elem_t); traits_t::_Copy_s(newbuf, size_in_bytes, pbase(), pos); #else traits_t::copy(newbuf, pbase(), pos); #endif setp(newbuf, newbuf + pos, newbuf + newlen); delete[] m_buf; m_buf = newbuf; *pptr() = c; pbump(1); return traits_t::not_eof(c_); } if (oldlen) { sync(); *pbase() = c; pbump(1); } else { const elem_t str[2] = { c, elem_t() }; OutputDebugStringX(str); } return traits_t::not_eof(c_); }
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; }
inline std::streamsize basic_dbgstreambuf<elem_t, traits_t>::xsputn( const elem_t* str, std::streamsize n) { if (n <= plen()) { #if _MSC_VER >= 1400 const size_t size_in_bytes = plen() * sizeof(elem_t); traits_t::_Copy_s(pptr(), size_in_bytes, str, n); #else traits_t::copy(pptr(), str, n); #endif const int off = static_cast<int>(n); pbump(off); return n; } const std::streamsize pos = ppos(); const std::streamsize newlen = pos + n; if (elem_t* const newbuf = new (std::nothrow) elem_t[newlen + 1]) { #if _MSC_VER >= 1400 size_t size_in_bytes = newlen * sizeof(elem_t); traits_t::_Copy_s(newbuf, size_in_bytes, pbase(), pos); #else traits_t::copy(newbuf, pbase(), pos); #endif setp(newbuf, newbuf + pos, newbuf + newlen); delete[] m_buf; m_buf = newbuf; #if _MSC_VER >= 1400 size_in_bytes = plen() * sizeof(elem_t); traits_t::_Copy_s(pptr(), size_in_bytes, str, n); #else traits_t::copy(pptr(), str, n); #endif const int off = static_cast<int>(n); pbump(off); return n; } const ptrdiff_t oldlen_ = epptr() - pbase(); if (oldlen_ == 0) { elem_t buf[2]; buf[1] = elem_t(); for (std::streamsize i = 0; i < n; ++i) { buf[0] = *str++; OutputDebugStringX(buf); } return n; } std::streamsize nn = n; if (std::streamsize len = plen()) { #if _MSC_VER >= 1400 const size_t size_in_bytes = len * sizeof(elem_t); traits_t::_Copy_s(pptr(), size_in_bytes, str, len); #else traits_t::copy(pptr(), str, len); #endif const int off = static_cast<int>(len); pbump(off); str += len; nn -= len; } const std::streamsize oldlen = static_cast<std::streamsize>(oldlen_); #if _MSC_VER >= 1400 const size_t size_in_bytes = oldlen * sizeof(elem_t); #endif for (;;) { sync(); if (nn <= oldlen) { #if _MSC_VER >= 1400 traits_t::_Copy_s(pbase(), size_in_bytes, str, nn); #else traits_t::copy(pbase(), str, nn); #endif const int off = static_cast<int>(nn); pbump(off); return n; } #if _MSC_VER >= 1400 traits_t::_Copy_s(pbase(), size_in_bytes, str, oldlen); #else traits_t::copy(pbase(), str, oldlen); #endif const int off = static_cast<int>(oldlen); pbump(off); str += oldlen; nn -= oldlen; } }