WEB开发网
开发学院WEB开发ASP.NET VC MakeUp 操作XML 阅读

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();
        }
    }
}

 

点击下载此文件

Tags:VC MakeUp XML

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接