//动态创建一个tab。 m_bsTab为CBaseTab 对象 class CBaseTab : public CTabCtrl
CRect rc(0, 75, 800, 580);
m_bsTab.Create(TCS_TABS, rc, this->GetActiveWindow(), IDC_TAB_BASE);
m_bsTab.ModifyStyle(0,LVS_OWNERDRAWFIXED,0);
现在我要改变tab标签的颜色(不是tab里面对话框的颜色),重载DrawItem
界面上并没有改变颜色,还有断点根本没有进入以下函数,求解
//
void CBaseTab::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
// TODO: 添加您的代码以绘制指定项
CBrush brushBK(m_colorBK);
char szTabText[100];
UINT bkColor;
CBrush *cbr;
TC_ITEM tci;
LOGBRUSH m_LogBrush;
cbr->GetLogBrush(&m_LogBrush);
bkColor = m_LogBrush.lbColor;
switch (lpDrawItemStruct->itemID)
{
case 0:
cbr = &brushBK;
m_colorBK = RGB(255,3,124);
break;
}
memset(szTabText, '\0', sizeof(szTabText));
tci.mask = TCIF_TEXT;
tci.pszText = szTabText;
tci.cchTextMax = sizeof(szTabText)-1; GetItem(lpDrawItemStruct->itemID, &tci);
FillRect(lpDrawItemStruct->hDC,&lpDrawItemStruct->rcItem,*cbr);
::SetBkColor(lpDrawItemStruct->hDC,bkColor);
TextOut(lpDrawItemStruct->hDC,
lpDrawItemStruct->rcItem.left,
lpDrawItemStruct->rcItem.top,
tci.pszText,
lstrlen(tci.pszText));
}
m_bsTab.ModifyStyle(0,TCS_OWNERDRAWFIXED,0);