VC6.0,MFC
代码示例:


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