Article ID: 206626
Article Last Modified on 11/21/2006
void CMyTabCtrl::DrawItem(LPDRAWITEMSTRUCT lpDIS)
{
TC_ITEM tci;
CDC* pDC = CDC::FromHandle(lpDIS->hDC);
CRect rect(lpDIS->rcItem);
char szTabText[256];
memset(szTabText,'\0',sizeof(szTabText));
tci.mask = TCIF_TEXT;
tci.pszText = szTabText;
tci.cchTextMax = sizeof(szTabText) -1;
GetItem(lpDIS->itemID, &tci);
if (lpDIS->itemAction & ODA_DRAWENTIRE)
{
pDC->TextOut(rect.left+5, rect.top+5, tci.pszText);
}
if ((lpDIS->itemState & ODS_SELECTED) &&
(lpDIS->itemAction & (ODA_SELECT | ODA_DRAWENTIRE)))
{
//Make the color of text of the selected tab to be BLUE.
pDC->SetTextColor(RGB(0,0,255));
pDC->TextOut(rect.left+5, rect.top+5, tci.pszText);
}
}
BOOL CMyPropertySheet::OnInitDialog()
{
BOOL bResult = CPropertySheet::OnInitDialog();
/* Subclass the tab control. */
m_myTabCtrl.SubclassWindow(GetTabControl()->m_hWnd);
/* Make it owner drawn. */
m_myTabCtrl.ModifyStyle(0,TCS_OWNERDRAWFIXED);
return bResult;
}
Additional query words: CTabCtrl CPropertySheet DrawItem owner draw
Keywords: kbhowto kbpropsheet KB206626