It may be too late for you, but the TabControl example that ships with MFC shows you how to do this. Basically, you use the CToolbarLabel class (which is implemented in the example for you) in the same way as you use CMFCToolBarButton and your spouses:
m_wndToolBar.ReplaceButton(ID_LABEL, CToolbarLabel(ID_LABEL, L"Some label: "));
For completeness, here is the CToolbarLabel implementation:
Title:
#pragma once class CToolbarLabel : public CMFCToolBarButton { DECLARE_SERIAL(CToolbarLabel) public: CToolbarLabel (UINT nID = 0, LPCTSTR lpszText = NULL); virtual void OnDraw (CDC* pDC, const CRect& rect, CMFCToolBarImages* pImages, BOOL bHorz = TRUE, BOOL bCustomizeMode = FALSE, BOOL bHighlight = FALSE, BOOL bDrawBorder = TRUE, BOOL bGrayDisabledButtons = TRUE); };
Implementation File:
#include "stdafx.h" #include "ToolbarLabel.h" IMPLEMENT_SERIAL(CToolbarLabel, CMFCToolBarButton, 1) CToolbarLabel::CToolbarLabel (UINT nID, LPCTSTR lpszText) { if (lpszText != NULL) { m_strText = lpszText; } m_bText = TRUE; m_nID = nID; m_iImage = -1; } void CToolbarLabel::OnDraw (CDC* pDC, const CRect& rect, CMFCToolBarImages* pImages, BOOL bHorz, BOOL , BOOL , BOOL , BOOL ) { UINT nStyle = m_nStyle; m_nStyle &= ~TBBS_DISABLED; CMFCToolBarButton::OnDraw (pDC, rect, pImages, bHorz, FALSE, FALSE, FALSE, FALSE); m_nStyle = nStyle; }
As you can see, it is very lightweight and just uses what the button already provides, so it also works for visual themes.