//**************************************************************************************
// FUNCTION: - DrawItem()
// RETURNS: -
// PARAMETERS: -
// COMMENTS:
//**************************************************************************************
void CMuteMainDlgTabCtrl::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
CRect rect = lpDrawItemStruct->rcItem;
IMAGEINFO info;
int nTabIndex = lpDrawItemStruct->itemID;
if (nTabIndex < 0) return;
BOOL bSelected = (nTabIndex == GetCurSel());
char label[64];
TC_ITEM tci;
tci.mask = TCIF_TEXT|TCIF_IMAGE;
tci.pszText = label;
tci.cchTextMax = 63;
if (!GetItem(nTabIndex, &tci )) return;
CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
if (!pDC) return;
int nSavedDC = pDC->SaveDC();
rect.top += ::GetSystemMetrics(SM_CYEDGE);
if (bSelected)
{
rect.bottom -= 1;
}
else
{
rect.bottom += 2;
}
pDC->FillSolidRect(rect, ::GetSysColor(COLOR_3DFACE));
pDC->SetBkMode(TRANSPARENT);
// Draw image
CImageList* pImageList = &m_pImgLst;
if (pImageList && tci.iImage >= 0)
{
rect.left += pDC->GetTextExtent(_T(" ")).cx; // Margin
// Get height of image so we
pImageList->GetImageInfo(nTabIndex, &info);
CRect ImageRect(info.rcImage);
int nYpos = rect.top;
pImageList->Draw(pDC, nTabIndex, CPoint(rect.left, nYpos), ILD_TRANSPARENT);
rect.left += ImageRect.Width();
}
if (bSelected) {
rect.top -= ::GetSystemMetrics(SM_CYEDGE);
pDC->DrawText(label, rect, DT_SINGLELINE|DT_VCENTER|DT_CENTER|DT_NOPREFIX);
rect.top += ::GetSystemMetrics(SM_CYEDGE);
} else {
pDC->DrawText(label, rect, DT_SINGLELINE|DT_BOTTOM|DT_CENTER|DT_NOPREFIX);
}
if (nSavedDC)
pDC->RestoreDC(nSavedDC);
}
//**************************************************************************************
// FUNCTION: -
// RETURNS: -
// PARAMETERS: -
// COMMENTS:
//**************************************************************************************
void CMuteMainDlgTabCtrl::PreSubclassWindow()
{
CTabCtrl::PreSubclassWindow();
//ModifyStyle(0, TCS_OWNERDRAWFIXED);
ModifyStyle(TCS_OWNERDRAWFIXED, 0);
}
//**************************************************************************************
// FUNCTION: -
// RETURNS: -
// PARAMETERS: -
// COMMENTS:
//**************************************************************************************
int CMuteMainDlgTabCtrl::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CTabCtrl::OnCreate(lpCreateStruct) == -1)
return -1;
//ModifyStyle(0, TCS_OWNERDRAWFIXED);
ModifyStyle(TCS_OWNERDRAWFIXED, 0);
return 0;
}