0

Using VS 2015. I have a dialog-based app (NOT a PropertySheet), and have a CTabCtrl-derived object in which I want to disable specific tabs. From what I've googled, owner-draw is the way to go. Fine, can understand that.

What I would like to do is START with an owner-drawn version that acts exactly like the non-owner-drawn version, and then start tweaking it variously to experiment. For example, I'd like to use things like

void CTabControl::DrawItem( LPDRAWITEMSTRUCT lpDrawItemStruct )
{
    CTabCtrl::DrawItem( lpDrawItemStruct );  // do exactly what unmodified does
}

so that I am basically calling everything the unmodified CTabCtrl would do to accomplish the drawing. Even the simplest starting point would be helpful. What routines do I need to override or intercept to do this?

I'm setting TCS_OWNERDRAWFIXED in PreSubclassWindow() and doing what I showed above, and one or two other things, but the result definitely doesn't look the same. For one thing, no text in the tabs.

I'd really love it if I could get some pointers on where to start. BTW, I'm creating the control programatically (no dialog resources) like this (CTabControl inherits from CTabCtrl):

MyDlg::OnInitDialog()
{
    ...
    m_tabctrl = new CTabControl();
    m_tabctrl->Create( TCS_TABS | TCS_BOTTOM | TCS_HOTTRACK | TCS_FIXEDWIDTH | WS_CHILD | WS_VISIBLE, dummyRect, this, ID_TABCTRL );
    ...
}
MPW
  • 329
  • 2
  • 13
  • With an owner-drawn tab control, it's the **parent** that needs to handle the drawing (unless you are using message reflection, I believe). Have you actually verified, that your `CTabControl::DrawItem` class member is called? – IInspectable Feb 10 '17 at 18:11
  • @IInspectable : I have indeed verified that member is being called. I would like to change only the class itself, so I would like to use message reflection, however that needs to be done. I'm mainly worried that I'm not handling some messages that would be automatically handled otherwise, or as you point out that the parent would normally handle invisibly. – MPW Feb 10 '17 at 18:23
  • 2
    I don't know if it has a way to make easier to make work your scenario, but I find easier to do things using `CMFCTabCtrl ` – sergiol Feb 12 '17 at 20:15
  • @sergiol : Thanks for the tip, ill investigate that. Was not aware of that class, looks promising. +1 for you. – MPW Feb 12 '17 at 23:19

0 Answers0