15,980
社区成员




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