0

When I have a SDI Document-View MFC application which uses CBCGPTabView as the main view, one of the tabs is a CEditView. If I send a custom message to the CBCGPTabView derived class and use GetTabControl().SetTabLabel() it not only changes the tab label but contents of the CEditView. Is there a way to prevent that?

animuson
  • 53,861
  • 28
  • 137
  • 147
user3161924
  • 1,849
  • 18
  • 33

2 Answers2

0

This is the workaround I have for now:

  // hack to work around ceditview getting its window contents changed
  CView* pview=GetView(tabi);
  if (pview->IsKindOf(RUNTIME_CLASS(CEditView))) {
    CString strexistingtext;
    pview->GetWindowText(strexistingtext);
    // change label
    tabctrl.SetTabLabel(tabi, strlabel);
    // put back text
    pview->SetWindowText(strexistingtext);
  }
  else {
    // change label
    tabctrl.SetTabLabel(tabi, strlabel);
  }
}
user3161924
  • 1,849
  • 18
  • 33
0

Another method is to override

virtual CString CBCGPMDIChildWnd::GetFrameText() const

And put / set there what you need.

Flaviu_
  • 1,285
  • 17
  • 33