OwnerDraw CTabView
"ivan.ivanov510" <ivan.ivanov510-/[email protected]> Tue, 02 Aug 2011 18:01:58 -0000
| Newsgroups | gmane.comp.windows.wtl |
|---|---|
| Message-ID | <[email protected]> |
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,
bkColor);
TextOut(lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top,
tcix.tciheader.pszText, lstrlen(tcix.tciheader.pszText)); } }};The
object not created. Calls: CCustomTabView::OnCreate ->
CCustomTabView::CreateTabControl -> CWindowImplBaseT::Create Debug error
Expression::IsWindow(m_hWnd) in atlwin.h CWindowImplBaseT< .. >::Create
after HWND hWnd = ::CreateWindowEx(..)
[Non-text portions of this message have been removed]
------------------------------------
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/wtl/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/wtl/join
(Yahoo! ID required)
<*> To change settings via email:
[email protected]
[email protected]
<*> To unsubscribe from this group, send an email to:
[email protected]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/