OwnerDraw CTabView
I want to display the tabs icon with different color font. I created my
class, but there were problems.class CCustomTabView : public
CTabView/*CWindowImpl<CCustomTabView,CTabView>*/, public
COwnerDraw<CCustomTabView>{public: BEGIN_MSG_MAP(CCustomTabView)
MESSAGE_HANDLER(WM_CREATE, OnCreate) //CHAIN_MSG_MAP(CTabView)
CHAIN_MSG_MAP_ALT(COwnerDraw<CCustomTabView>, 1)
REFLECT_NOTIFICATIONS() END_MSG_MAP()
HBRUSH hBr; UINT bkColor;
LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL&
bHandled) { CreateTabControl(); return 0; }
bool CreateTabControl() { m_tab.Create(m_hWnd, rcDefault, NULL,
WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | TCS_TOOLTIPS, 0,
m_nTabID); ATLASSERT(m_tab.m_hWnd != NULL); if(m_tab.m_hWnd == NULL)
return false;
m_tab.SetFont(AtlGetDefaultGuiFont());
m_tab.SetItemExtra(sizeof(TABVIEWPAGE));
m_cyTabHeight = this->CalcTabHeight();
return true; }
void DrawItem(LPDRAWITEMSTRUCT pDS) { LPDRAWITEMSTRUCT lpdis =
pDS/*(LPDRAWITEMSTRUCT) lParam*/; // item drawing information
if ( m_hWnd == lpdis->hwndItem) // is this the tab control? { hBr =
CreateSolidBrush(RGB(255, 0, 0)); bkColor = RGB(0, 0, 255);
int cchBuff = 100; LPTSTR szTabText = NULL; ATLTRY(szTabText = new
TCHAR[cchBuff]); if(szTabText == NULL) return;
SecureHelper::strcpy_x(szTabText, cchBuff, _T(""));
TCITEMEXTRA tcix = { 0 }; tcix.tciheader.mask = TCIF_PARAM;
tcix.tciheader.pszText = szTabText; tcix.tciheader.cchTextMax =
sizeof(szTabText)-1;
if(m_tab.GetItem(lpdis->itemID, tcix) == FALSE) return;
FillRect(lpdis->hDC, &lpdis->rcItem, hBr); SetBkColor(lpdis->hDC,
(Continue reading)