CTabCtrl控件标签的相关设置

 


原文链接: http://blog.csdn.net/happyhell/article/details/6012177

1、 获得CTabCtrl标签高度:
CRect rc;
CTabCtrl *pTabCtrl = GetTabControl();
pTabCtrl->GetItemRect(&rc);
int nHeight = rc.Height();

2、修改CTabCtrl标签上的文字:

// In this example a CTabCtrl data member, m_TabCtrl, changes the
// text of the tabs in the tab control. A call to GetItem is used
// to get the current text, and then the text is changed. A call
// to SetItem is used to update the tab with the new text.

void CTabDlg::OnChangeItem()
{
  TCITEM tcItem;
  CString pszString;

  // Get text for the tab item.
  GetDlgItemText(IDC_ITEM_TEXT, pszString);

  // Get the current tab item text.
  TCHAR buffer[256] = {0};
  tcItem.pszText = buffer;
  tcItem.cchTextMax = 256;
  tcItem.mask = TCIF_TEXT;
  m_TabCtrl.GetItem(0, &tcItem);
  TRACE(_T("Changing item text from %s to %s..."), tcItem.pszText, pszString);

  // Set the new text for the item.
  tcItem.pszText = pszString.LockBuffer();

  // Set the item in the tab control.
  m_TabCtrl.SetItem(0, &tcItem);

  pszString.UnlockBuffer();
}

3、设置标签尺寸:
pTabCtrl->SetItemSize(CSize(100,100)); // 第一个参数为长度,第二个参数为高度

4、设置标签字体:
m_Font.CreateFont(14,0,0,0,300,0,0,0,1,0,0,0,0,_T("Arial"));
pTabCtrl->SetFont(&m_Font);

 

 

 

 

 

 

posted @ 2015-06-15 11:46  huhu0013  阅读(2319)  评论(0编辑  收藏  举报