drawtext 换行有关问题

drawtext 换行问题?
本帖最后由 VisualEleven 于 2013-02-21 15:03:15 编辑
void TextMiult::DrawItem(LPDRAWITEMSTRUCT lp) 
{
CDC *pDC=CDC::FromHandle(lp->hDC);
CRect rc;
GetClientRect(&rc);
CFont font;
font.CreatePointFont(90,"Arial Unicode MS");
pDC->SetBkMode(TRANSPARENT);
//pDC->SelectObject(font);//½«ËûÑ¡Ôñµ½É豸ÖÐ
pDC->SetTextColor(RGB(255,255,255));
CString str;
GetWindowText(str);
CRect boundary(0,0,40,20);
        //
CRect rect;
rect.left = rect.top = 0;
rect.right = 200;
        rect.bottom = rc.bottom;
//rect(0,0,boundary.Width(),boundary.Height());

    int height=pDC->DrawText(str,rc,DT_CALCRECT|DT_CENTER|DT_EDITCONTROL|DT_WORDBREAK);
        rect=boundary;
if (boundary.Height()>height)
{
rc.top+=(boundary.Height()-height)/2;
}
         
pDC->DrawText(str,rc,DT_CENTER|DT_EDITCONTROL|DT_WORDBREAK);

}
//这是画的地方。

void TextMiult:: Create(LPCTSTR lpszCaption,CWnd* pr,CRect rc,UINT id)
{
CButton::Create(lpszCaption,WS_VISIBLE|WS_CHILD,rc,pr,id);
}

//在OnInitDialog()里
m_shi=new TextMiult();
m_shi->Create("122222222222222222222222222222222222222",this,CRect(70,90,200,240),0);

这是哪里出了问题。不解求解呀。

------解决方案--------------------
m_shi->Create("12222222222222222 2222222222222222222222",this,CRect(70,90,200,240),0); 
加个空格(或者其它字符比如回车换行符号)试试
------解决方案--------------------
DrawText(str,rc,DT_CALCRECT
------解决方案--------------------
DT_CENTER
------解决方案--------------------
DT_EDITCONTROL
------解决方案--------------------
DT_WORDBREAK);
我记得 单行的 才可以DT_CENTER, 你查查。
------解决方案--------------------
button里面有multiline属性 true
------解决方案--------------------
邮箱:657097484@qq.com

菜鸟一名


------解决方案--------------------
21楼的你还不明白??

这个你还明白??