我是根据这边来做的,没有效果 是不是哪里少了?
http://support.microsoft.com/kb/179909/zh-cn代码如下:
tabControl 设置为owner draw CBrush m_br;
m_br.CreateSolidBrush(RGB(0, 255, 0));
void CMydlgDlg::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct)
{
CDialog::OnDrawItem(nIDCtl, lpDrawItemStruct); char szTabText[100];
RECT rect;
UINT bkColor;
CBrush *cbr;
TC_ITEM tci;
CTabCtrl *pTabCtrl = (CTabCtrl *)GetDlgItem(IDC_TAB1);
if (pTabCtrl->m_hWnd == lpDrawItemStruct->hwndItem)
{
switch (lpDrawItemStruct->itemID)
{
default:
cbr = &m_br;
bkColor = RGB(255,0,0);
break;
}
memset(szTabText, '\0', sizeof(szTabText));
tci.mask = TCIF_TEXT;
tci.pszText = szTabText;
tci.cchTextMax = sizeof(szTabText)-1;
pTabCtrl->GetItem(lpDrawItemStruct->itemID, &tci);
CDC *dc = CDC::FromHandle(lpDrawItemStruct->hDC);
dc->FillRect(&lpDrawItemStruct->rcItem, cbr);
dc->SetBkColor(bkColor);
TextOut(lpDrawItemStruct->hDC,
lpDrawItemStruct->rcItem.left,
lpDrawItemStruct->rcItem.top,
tci.pszText,
lstrlen(tci.pszText));
}
}
http://support.microsoft.com/kb/179909/zh-cn代码如下:
tabControl 设置为owner draw CBrush m_br;
m_br.CreateSolidBrush(RGB(0, 255, 0));
void CMydlgDlg::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct)
{
CDialog::OnDrawItem(nIDCtl, lpDrawItemStruct); char szTabText[100];
RECT rect;
UINT bkColor;
CBrush *cbr;
TC_ITEM tci;
CTabCtrl *pTabCtrl = (CTabCtrl *)GetDlgItem(IDC_TAB1);
if (pTabCtrl->m_hWnd == lpDrawItemStruct->hwndItem)
{
switch (lpDrawItemStruct->itemID)
{
default:
cbr = &m_br;
bkColor = RGB(255,0,0);
break;
}
memset(szTabText, '\0', sizeof(szTabText));
tci.mask = TCIF_TEXT;
tci.pszText = szTabText;
tci.cchTextMax = sizeof(szTabText)-1;
pTabCtrl->GetItem(lpDrawItemStruct->itemID, &tci);
CDC *dc = CDC::FromHandle(lpDrawItemStruct->hDC);
dc->FillRect(&lpDrawItemStruct->rcItem, cbr);
dc->SetBkColor(bkColor);
TextOut(lpDrawItemStruct->hDC,
lpDrawItemStruct->rcItem.left,
lpDrawItemStruct->rcItem.top,
tci.pszText,
lstrlen(tci.pszText));
}
}
//CDialog::OnDrawItem(nIDCtl, lpDrawItemStruct); //这个不要了,测试成功
>>>>>>>>>>>>>>>>>>>>也不行啊