how to get the CWnd pointer in a tab control |
Post Reply |
Author | |
rienzi
Groupie Joined: 20 August 2009 Status: Offline Points: 38 |
Post Options
Thanks(0)
Posted: 28 August 2009 at 5:12am |
I'm wondering how to get the CWnd pointer which has been added in a CXTPTabControl object.
I add a CView object to CXTPTabControl as showed in the following codes: BOOL CProductSysView::AddView(CRuntimeClass* pViewClass, LPCTSTR lpszTitle, int nIcon) { CCreateContext contextT; contextT.m_pCurrentDoc = GetDocument(); contextT.m_pNewViewClass = pViewClass; contextT.m_pNewDocTemplate = GetDocument()->GetDocTemplate(); CWnd* pWnd; TRY { pWnd = (CWnd*)pViewClass->CreateObject(); if (pWnd == NULL) { AfxThrowMemoryException(); } } CATCH_ALL(e) { TRACE0( "Memory Overflow\n" ); // Note: DELETE_EXCEPTION(e) not required return FALSE; } END_CATCH_ALL DWORD dwStyle = AFX_WS_DEFAULT_VIEW; dwStyle &= ~WS_BORDER; int nTab = m_wndTabControl.GetItemCount(); // Create with the right size (wrong position) CRect rect(0,0,0,0); if (!pWnd->Create(NULL, NULL, dwStyle, rect, &m_wndTabControl, (AFX_IDW_PANE_FIRST + nTab), &contextT)) { TRACE0( "warning: Can not create\n" ); // pWnd will be cleaned up by PostNcDestroy return NULL; } m_wndTabControl.InsertItem(nTab, lpszTitle, pWnd->GetSafeHwnd(), -1/*nIcon*/); pWnd->SetOwner(this); return TRUE; } m_wndTabControl is a CXTPTabControl type of member variable. Now the pWnd pointer is a local variable. I want to know how to get its pointer in other functions. many thanks |
|
rienzi
Groupie Joined: 20 August 2009 Status: Offline Points: 38 |
Post Options
Thanks(0)
|
OK, I got it from the samples
the following code: CView* pView = DYNAMIC_DOWNCAST(CView, CWnd::FromHandle(m_wndTabControl.GetSelectedItem()->GetHandle())); ASSERT_KINDOF(CView, pView); can get the right CView object pointer then this post can be terminated |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |