This is what I used to derive from the CTabCtrl class:
And one of the dialogs I inserted into the tab1 is:Code:IMPLEMENT_DYNCREATE(CDialogTabs, CDialog) CDialogTabs::CDialogTabs(CWnd* pParent /*=NULL*/) : CDialog(CDialogTabs::IDD) { m_DialogID[0] = IDD_EDIT_TISSUE; m_DialogID[1] = IDD_EDITCVECTOR; m_DialogID[2] = IDD_EDITCELLTYPE; } void CDialogTabs::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); DDX_Control(pDX, IDC_TAB1, tab1); } BOOL CDialogTabs::OnInitDialog( ) { CimDBManagerDoc *pDoc = (CimDBManagerDoc *) theApp.m_pDoc; CDialog::OnInitDialog(); TC_ITEM TabCtrlItem; CRect WindowRect; TabCtrlItem.mask = TCIF_TEXT; TabCtrlItem.pszText = _T("Edit Cell Type"); if(tab1.InsertItem(0,&TabCtrlItem)==-1) MessageBox(_T("InsertItem 1 failed")); TabCtrlItem.pszText = _T("Edit Construct Vector"); if(tab1.InsertItem(0,&TabCtrlItem)==-1) MessageBox(_T("InsertItem 2 failed")); TabCtrlItem.pszText = _T("Edit Tissue"); if(tab1.InsertItem(0,&TabCtrlItem)==-1) MessageBox(_T("InsertItem 3 failed")); //Determine the size of the area for the contents tab1.GetClientRect(&m_ClientRect); tab1.AdjustRect(FALSE, &m_ClientRect); //Determine the offset within the view's client area tab1.GetWindowRect(&WindowRect); GetParent()->ScreenToClient(WindowRect); m_ClientRect.OffsetRect(WindowRect.left-15, WindowRect.top-40); //Complete the initialization tab1.SetCurSel(0); CreateContents(); return TRUE; } BEGIN_MESSAGE_MAP(CDialogTabs, CDialog) ON_NOTIFY(TCN_SELCHANGE, IDC_TAB1, &CDialogTabs::OnSelchangeTab) END_MESSAGE_MAP() void CDialogTabs::CreateContents() { int CurSel = tab1.GetCurSel(); if(m_Dialog.m_hWnd) m_Dialog.DestroyWindow(); if(!m_Dialog.Create(m_DialogID[CurSel], &tab1)) TRACE0("Dialog not created\n"); m_Dialog.MoveWindow(m_ClientRect); m_Dialog.ShowWindow(SW_SHOW); GetParent()->RedrawWindow(); } void CDialogTabs::OnSelchangeTab(NMHDR* pNMHDR, LRESULT* pResult) { CreateContents(); }
(m_dbPatient here is a CRecordSet)Code:// CEditTissue dialog IMPLEMENT_DYNAMIC(CEditTissue, CDialog) CEditTissue::CEditTissue(CWnd* pParent /*=NULL*/) : CDialog(CEditTissue::IDD, pParent) , m_tThickness(_T("")) { } void CEditTissue::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); ... DDX_Control(pDX, IDC_TISSUEPATIENT, m_tPatient1); ... } BOOL CEditTissue::OnInitDialog() { CDialog::OnInitDialog(); GetPatientList(); return TRUE; } ... // CEditTissue message handlers void CEditTissue::GetPatientList() { if (!m_dbPatient.IsOpen()) m_dbPatient.Open(); m_dbPatient.m_strFilter = _T(""); m_dbPatient.Requery(); while(m_dbPatient.IsOpen()&&!m_dbPatient.IsEOF()) { m_tPatient1.AddString(m_dbPatient.m_Name); m_dbPatient.MoveNext(); } m_dbPatient.Close(); }
The tabs seems fine. When I clicked on them, the window will toggle through the 3 dialogs.
But if I put a breakpoint on BOOL CEditTissue::OnInitDialog();
The application never go to this initialization. So the
GetPatientList(); never gets to run.
in EditTissue.h I have:My guess is the m_Dialog.ShowWindow(SW_SHOW) only display the CEditTissue Dialog, but not like DoModel() will actually run the class.Code:protected: virtual BOOL OnInitDialog( );
Could anybody give me a hint of how to solve this?
Thanks,




Reply With Quote