0
votes

I have a MFC application that have a class who inherits from CTabCtrl, on my Main Dialog::OnInit() Method I do.

tabCtrl.InsertItem(0, _T("Tab 1"));
tabCtrl.InsertItem(1, _T("Tab 2"));
tabCtrl.InitDialogs();

tabCtrl.ActivateTabDialogs();
tabCtrl.ShowWindow(SW_SHOW);

tabCtrl is a variable from a class that inherits from CTabCtrl, the method InitDialogs is:

m_Dialog[0]->Create(m_DialogID[0], this);
m_Dialog[1]->Create(m_DialogID[1], this);
m_Dialog[0]->ShowWindow(SW_SHOW);

m_Dialog* is contains both dialog class that I drawn from the resource class.

I see both tabs as I drawn it when I run the program, but when I do something like

UpdateData(TRUE);
valueTest = "tEST";
UpdateData(FALSE);

I get an assertion fail error. My DoDataExchange is being called and it looks like:

 void ConfigDialog::DoDataExchange(CDataExchange* pDX)
{
    CDialogEx::DoDataExchange(pDX);
    DDX_Text(pDX, IDC_EDIT1, valueTest);
}

I've been strugling with this for days, and I only been able to found examples with dummy tabs who doesn't have any controls inside them. Is there any step that I'm missing?

Update: The assertion error show this

Microsoft Visual C++ Runtime Library --------------------------- Debug Assertion Failed! Program: C:\Windows\SYSTEM32\mfc140d.dll File: f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\wincore.cpp Line: 4355 For information on how your program can cause an assertion failure, see the Visual C++ documentation on asserts

And it fails to UpdateData(TRUE) sentence

1
What's your actual problem? That you're seeing an assert fail? - Lynn Crumbling
My problem is that I can't change the properties of the controls, when I try to do it I get an assert fail. - Pablo Iocco
Please post the exact error message of the assertion dialog. You can copy the text using [Ctrl]+C. A screenshot can help, but that's not strictly required. - IInspectable
@LynnCrumbling: UpdateData is an MFC implementation, that stores data from controls to attached instance variables, or restores the control contents back (depending on the argument). - IInspectable
The line of code that fails is ASSERT(::IsWindow(m_hWnd)); // calling UpdateData before DoModal? (the comment is interesting). Unless I'm using a different version of MFC than you are. You should update your question and include both the assertion dialog text as well as the code with the failed assertion (press Debug to get there), including a few more lines. - IInspectable

1 Answers

0
votes

I assume it's an edit control because it has the ID of IDC_EDIT1. The ASSERT is being given because you do no have a window with the ID of IDC_EDIT1 as a child window of ConfigDialog. Is it a child of one of the tab controls? The DDX_* macros will only work for child windows of your dialog class.

If you have a child window of some tab, try something like:

tabCtrl.SetDlgItemText(IDC_EDIT1, valueTest);

To retrieve it,

tabCtrl.GetDlgItemTText(IDC_EDIT1, valueTest);