CEdit 垂直居中

首先要设置为多行模式

 

  CRect rc;
  m_ctlSearchBox.GetClientRect(&rc);
  CDC* pDC = m_ctlSearchBox.GetDC();
  TEXTMETRIC tm;
  pDC->GetTextMetrics(&tm);
  int nFontHeight = tm.tmHeight + tm.tmExternalLeading;
  int nMargin = (rc.Height() - nFontHeight) / 2;
  rc.DeflateRect(0,nMargin);
  m_ctlSearchBox.SetRectNP(&rc);

 

 

http://topic.csdn.net/t/20030606/14/1884129.html

http://hi.baidu.com/171808966/blog/item/0aaaa36e35878bd181cb4aaa.html

http://hi.baidu.com/dcrencq/blog/item/4bdb50c215f366130ff47722.html
http://topic.csdn.net/t/20030606/14/1884129.html

http://hi.baidu.com/171808966/blog/item/0aaaa36e35878bd181cb4aaa.html

http://hi.baidu.com/dcrencq/blog/item/4bdb50c215f366130ff47722.html
http://topic.csdn.net/t/20030606/14/1884129.html

http://hi.baidu.com/171808966/blog/item/0aaaa36e35878bd181cb4aaa.html

http://hi.baidu.com/dcrencq/blog/item/4bdb50c215f366130ff47722.html

你可能感兴趣的:(CEdit 垂直居中)