VC MakeUp 操作XML
2010-10-19 13:46:55 来源:WEB开发网核心提示:void CTestView::OnDraw(CDC* pDC){ CDocument* pDoc = GetDocument(); CMarkup xml; if( !xml.Load(theApp.m_sAppPath + _T("\\config.xml")) )
void CTestView::OnDraw(CDC* pDC) { CDocument* pDoc = GetDocument(); CMarkup xml; if( !xml.Load(theApp.m_sAppPath + _T("\\config.xml")) ) return; CFont font; SetBkMode(pDC->m_hDC,TRANSPARENT); font.CreatePointFont(110,"宋体",NULL); CFont *pOldFont = pDC->SelectObject(&font); CString currentString = _T(""),heightString = _T(""),colorString = _T(""); int posX = 10 , posY = 5; CSize sizeofdata; //加载页面数据 while ( xml.FindChildElem(m_sheet) ) { xml.IntoElem(); while (xml.FindChildElem("LINE")) { posX = 10; xml.IntoElem(); heightString = xml.GetAttrib(_T("HEIGHT")); int height = atoi(heightString); posY += height; colorString = xml.GetAttrib(_T("COLOR")); while (xml.FindChildElem("TEXT")) { currentString = xml.GetChildData(); pDC->TextOut(posX ,posY,currentString); sizeofdata = pDC->GetTextExtent(currentString); posX += sizeofdata.cx; } posY += sizeofdata.cy; xml.OutOfElem(); } } }
更多精彩
赞助商链接