title: Adding tabs to CTabCtrl in MFC
body: <p>I am trying to add a CTabCtrl into my MFC application.  I am trying to follow the MSDN directly.</p>
  <p><img src="https://i.stack.imgur.com/hb1rB.png" alt="MSDN Adding Tab" /></p>
  <p>*<a href="https://msdn.microsoft.com/en-us/library/dcz8wdb3.aspx" rel="nofollow noreferrer">MSDN: Adding Tabs to Tab Control</a></p>
  <p>Here is what I have tried:</p>
  <p><code>DDX_Control(pDX, TAB1, m_TabCtrl);</code></p>
  <pre><code>TC_ITEM ti;
  ti.mask = TCIF_TEXT;
  ti.pszText = _T(&quot;First Tab&quot;);
  
  m_TabCtrl.InsertItem(0,&amp;ti);
  </code></pre>
  <p>I am receiving the following error message:
  <img src="https://i.stack.imgur.com/g2yS5.png" alt="Assertion Fail" /></p>
  <p>If I hit ignore, my CTabCtrl is shown, but without any tabs (just a gray square).  If I hit retry, I get the breakpoint at:</p>
  <pre><code>_AFXCMN_INLINE BOOL CTabCtrl::SetItem(int nItem, TCITEM* pTabCtrlItem)
  { ASSERT(::IsWindow(m_hWnd)); return (BOOL)::SendMessage(m_hWnd, TCM_SETITEM, nItem, (LPARAM)pTabCtrlItem); }
  </code></pre>
  <p>I have tried adding the header <code>#include &quot;afxcmn.h&quot;</code> but it does not change anything.</p>
  <p>I am simply trying to get named tabs to show on my application as a first step.  Eventually I wish for the tabs to show modeless dialogs.  Can someone tell me what I am doing wrong?  Is there a better way to use tabs in MFC?</p>