怎么让CStatic或CButton既垂直居中,又可以自动换行
展开全部
只需要派生一个CButton,重载DrawItem
void CSkinButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
// TODO: Add your code to draw the specified item
CDC *pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
CRect rcClient;
GetClientRect( &rcClient );
CString sText;
GetWindowText( sText );
pDC->DrawText( sText,rcClient, DT_CENTER|DT_WORDBREAK );
}
注意要把Button的属性加上own draw
void CSkinButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
// TODO: Add your code to draw the specified item
CDC *pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
CRect rcClient;
GetClientRect( &rcClient );
CString sText;
GetWindowText( sText );
pDC->DrawText( sText,rcClient, DT_CENTER|DT_WORDBREAK );
}
注意要把Button的属性加上own draw
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询