DrawText换行处理

//CString  str;

//str= "@@@";//符号—汉字—数字等

WCHAR* pwch = newWCHAR[str.GetLength() * 2];

int nLeng =MultiByteToWideChar(CP_ACP,NULL,str,str.GetLength(),pwch,0);//得到转化字长

MultiByteToWideChar(CP_ACP,NULL,str,str.GetLength(),pwch,nLeng);

pDC->SelectObject(&……);//设置字体

if(nLeng >15)//我这里是15个字以后就换行

{

    ::DrawTextW(pDC->m_hDC,pwch,nLeng/2,CRect(rect1)), DT_CENTER |DT_VCENTER | DT_SINGLELINE);//对半分割

      ……//其他操作;

     ::DrawTextW(pDC->m_hDC,pwch+nLeng/2,nLeng-nLeng/2,CRect(rect2),DT_CENTER | DT_VCENTER | DT_SINGLELINE);

}

delete pwch;

你可能感兴趣的:(DrawText换行处理)