int x = rectDraw.left;
int y = rectDraw.top;
//计算字符串的逻辑坐标的长度
int m_lenofherz = strText.GetLength() * tm.tmAveCharWidth;
int m_lenofvert = 0;//m_lenofherz:为字符横向显示字符时,字符的总宽度 m_lenofvert:为字符竖直显示时,字符的竖直高度
//计算字符串逻辑坐标的高度
for(int i=0;i<strText.GetLength();)
{
//if (strText & 0x80) //字符集为Unicode时,汉字和英文字符都占一个字节
//{//是汉字时,一次取两个字节
// strTemp = strText.GetAt(i++);
// strTemp += strText.GetAt(i++);
// m_lenofvert += tm.tmHeight;
//}
//else
{//英文时,一次取一个字节
strTemp += strText.GetAt(i++);
m_lenofvert += tm.tmHeight;
}
}
if(m_lenofherz < abs(rectDraw.Width()))
{
pDC->SetTextAlign(TA_CENTER);
pDC->TextOut(rectDraw.CenterPoint().x,rectDraw.CenterPoint().y,m_trackname); // //道的名称
}
else
{
if(m_lenofvert<=abs(rectDraw.Height()))
{
y -= (abs(rectDraw.Height()) - m_lenofvert)/2;
}
strTemp = _T("");
for(int i=0;i<strText.GetLength();)
{
//if (strText & 0x80) //字符集为Unicode时,汉字和英文字符都占一个字节
//{//汉字
// strTemp = strText.GetAt(i++);
// strTemp += strText.GetAt(i++);
// x = rectDraw.CenterPoint().x ;
// pDC->TextOut(x, y, strTemp);
// y -= tm.tmHeight;
// CString m_s;
// m_s.Format(_T("y %d/n,rectDraw.Height() %d/n,rectDraw.top %d/n,rectDraw.bottom %d/n,m_lenofvert %d/n"),y,rectDraw.Height(),rectDraw.top,rectDraw.bottom,m_lenofvert);
// m_s +=strTemp;
// AfxMessageBox(m_s);
//}
//else
{
strTemp+= strText.GetAt(i++);
if (strTemp==_T("(")||strTemp==_T("("))
{
strTemp = _T("(");
continue;
}
CString m_s = _T("");
if((i)<=(strText.GetLength()-1))
{
m_s = strText.GetAt(i);
if (m_s==_T(")")||m_s==_T(")"))
{
strTemp += _T(")");
i++;
}
}
x = rectDraw.CenterPoint().x ;
pDC->TextOut(x, y, strTemp);
y -= tm.tmHeight;
strTemp = _T("");
}
}
}
int y = rectDraw.top;
//计算字符串的逻辑坐标的长度
int m_lenofherz = strText.GetLength() * tm.tmAveCharWidth;
int m_lenofvert = 0;//m_lenofherz:为字符横向显示字符时,字符的总宽度 m_lenofvert:为字符竖直显示时,字符的竖直高度
//计算字符串逻辑坐标的高度
for(int i=0;i<strText.GetLength();)
{
//if (strText & 0x80) //字符集为Unicode时,汉字和英文字符都占一个字节
//{//是汉字时,一次取两个字节
// strTemp = strText.GetAt(i++);
// strTemp += strText.GetAt(i++);
// m_lenofvert += tm.tmHeight;
//}
//else
{//英文时,一次取一个字节
strTemp += strText.GetAt(i++);
m_lenofvert += tm.tmHeight;
}
}
if(m_lenofherz < abs(rectDraw.Width()))
{
pDC->SetTextAlign(TA_CENTER);
pDC->TextOut(rectDraw.CenterPoint().x,rectDraw.CenterPoint().y,m_trackname); // //道的名称
}
else
{
if(m_lenofvert<=abs(rectDraw.Height()))
{
y -= (abs(rectDraw.Height()) - m_lenofvert)/2;
}
strTemp = _T("");
for(int i=0;i<strText.GetLength();)
{
//if (strText & 0x80) //字符集为Unicode时,汉字和英文字符都占一个字节
//{//汉字
// strTemp = strText.GetAt(i++);
// strTemp += strText.GetAt(i++);
// x = rectDraw.CenterPoint().x ;
// pDC->TextOut(x, y, strTemp);
// y -= tm.tmHeight;
// CString m_s;
// m_s.Format(_T("y %d/n,rectDraw.Height() %d/n,rectDraw.top %d/n,rectDraw.bottom %d/n,m_lenofvert %d/n"),y,rectDraw.Height(),rectDraw.top,rectDraw.bottom,m_lenofvert);
// m_s +=strTemp;
// AfxMessageBox(m_s);
//}
//else
{
strTemp+= strText.GetAt(i++);
if (strTemp==_T("(")||strTemp==_T("("))
{
strTemp = _T("(");
continue;
}
CString m_s = _T("");
if((i)<=(strText.GetLength()-1))
{
m_s = strText.GetAt(i);
if (m_s==_T(")")||m_s==_T(")"))
{
strTemp += _T(")");
i++;
}
}
x = rectDraw.CenterPoint().x ;
pDC->TextOut(x, y, strTemp);
y -= tm.tmHeight;
strTemp = _T("");
}
}
}