Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. change tab text color

change tab text color

Scheduled Pinned Locked Moved C / C++ / MFC
tutorial
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jeepoo
    wrote on last edited by
    #1

    how to change tab text color in tab control.give samples plz.

    L 1 Reply Last reply
    0
    • J jeepoo

      how to change tab text color in tab control.give samples plz.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      you need to make an owner draw tab control http://www.codeproject.com/tabctrl/customtab.asp if u didnt understand the code let me know

      P 1 Reply Last reply
      0
      • L Lost User

        you need to make an owner draw tab control http://www.codeproject.com/tabctrl/customtab.asp if u didnt understand the code let me know

        P Offline
        P Offline
        prathuraj
        wrote on last edited by
        #3

        i want to give color to tab caption for each tab in that control.like,if a tab control have two tabs like tab1 and tab2.am want to change tab1 & tab2 to colored one.how to do this.

        L 1 Reply Last reply
        0
        • P prathuraj

          i want to give color to tab caption for each tab in that control.like,if a tab control have two tabs like tab1 and tab2.am want to change tab1 & tab2 to colored one.how to do this.

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          see this code void CEnTabCtrl::DrawItem(LPDRAWITEMSTRUCT lpdis) { TC_ITEM tci; CDC* pDC = CDC::FromHandle(lpdis->hDC); HIMAGELIST hilTabs = (HIMAGELIST)TabCtrl_GetImageList(GetSafeHwnd()); BOOL bSelected = (lpdis->itemID == (UINT)GetCurSel()); BOOL bColor = (s_dwCustomLook & ETC_COLOR); CRect rItem(lpdis->rcItem); if (bSelected) rItem.bottom -= 1; else rItem.bottom += 2; // tab // blend from back color to COLOR_3DFACE if 16 bit mode or better COLORREF crFrom = GetTabColor(bSelected); if (s_dwCustomLook & ETC_GRADIENT && pDC->GetDeviceCaps(BITSPIXEL) >= 16) { COLORREF crTo = bSelected ? ::GetSysColor(COLOR_3DFACE) : Darker(!bColor || m_crBack == -1 ? ::GetSysColor(COLOR_3DFACE) : m_crBack, 0.7f); int nROrg = GetRValue(crFrom); int nGOrg = GetGValue(crFrom); int nBOrg = GetBValue(crFrom); int nRDiff = GetRValue(crTo) - nROrg; int nGDiff = GetGValue(crTo) - nGOrg; int nBDiff = GetBValue(crTo) - nBOrg; int nHeight = rItem.Height(); for (int nLine = 0; nLine < nHeight; nLine += 2) { int nRed = nROrg + (nLine * nRDiff) / nHeight; int nGreen = nGOrg + (nLine * nGDiff) / nHeight; int nBlue = nBOrg + (nLine * nBDiff) / nHeight; pDC->FillSolidRect(CRect(rItem.left, rItem.top + nLine, rItem.right, rItem.top + nLine + 2), RGB(nRed, nGreen, nBlue)); } } else // simple solid fill pDC->FillSolidRect(rItem, crFrom); // text & icon rItem.left += PADDING; rItem.top += PADDING + (bSelected ? 1 : 0); pDC->SetBkMode(TRANSPARENT); CString sTemp; tci.mask = TCIF_TEXT | TCIF_IMAGE; tci.pszText = sTemp.GetBuffer(100); tci.cchTextMax = 99; GetItem(lpdis->itemID, &tci); sTemp.ReleaseBuffer(); // icon if (hilTabs) { ImageList_Draw(hilTabs, tci.iImage, *pDC, rItem.left, rItem.top, ILD_TRANSPARENT); rItem.left += 16 + PADDING; } // text rItem.right -= PADDING; FormatText(sTemp, pDC, rItem.Width()); COLORREF col; col=RGB(255,0,0); pDC->SetTextColor(col); pDC->DrawText(sTemp, rItem, DT_NOPREFIX | DT_CENTER); }

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups