![]() |
A Question About the Tab Control |
Post Reply ![]() |
Author | |
fireflame ![]() Groupie ![]() Joined: 15 March 2007 Status: Offline Points: 21 |
![]() ![]() ![]() ![]() ![]() Posted: 30 July 2008 at 4:05am |
I using a CXTPTabControl to show some views in a project,the code is following:
CWnd* CMonitorManTabCtrl::AddView(CRuntimeClass* pViewClass, LPCTSTR lpszTitle, int nIcon,CRect rect)
{ CCreateContext contextT; contextT.m_pNewViewClass = pViewClass; CWnd* pWnd;
TRY { pWnd = (CWnd*)pViewClass->CreateObject(); if (pWnd == NULL) { AfxThrowMemoryException(); } } CATCH_ALL(e) { TRACE0( "Out of memory creating a view.\n" ); return FALSE; } END_CATCH_ALL DWORD dwStyle = AFX_WS_DEFAULT_VIEW;
dwStyle &= ~WS_BORDER; int nTab = GetItemCount();
if (!pWnd->Create(NULL, NULL, dwStyle, rect, this, (AFX_IDW_PANE_FIRST + nTab), &contextT)) { TRACE0( "Warning: couldn't create client tab for view.\n" ); return NULL; } this->SetSelectedItem(this->InsertItem(nTab, lpszTitle, pWnd->GetSafeHwnd(), nIcon));
pWnd->SetOwner(this);
return pWnd;
} when i clicked the close button, how can i also destroy the view inside?
the code is following
void CMonitorManTabCtrl::OnNavigateButtonClick(CXTPTabManagerNavigateButton* pButton)
{ CWnd *pWnd = NULL;
if (pButton->GetID() == xtpTabNavigateButtonClose) { CXTPTabManagerItem *pItem = this->GetSelectedItem(); pWnd = (CWnd*)(LPVOID)pItem->GetData(); } if (pWnd)
{ pWnd->DestroyWindow(); } } here pWnd is a point to NULL,how can i get the RUNTIME_CLASS view?
|
|
![]() |
|
Oleg ![]() Senior Member ![]() Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
![]() ![]() ![]() ![]() ![]() |
Hi,
Instead GetData call CWnd::FromHandle(pItem->GetHandle());
|
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
![]() |
|
fireflame ![]() Groupie ![]() Joined: 15 March 2007 Status: Offline Points: 21 |
![]() ![]() ![]() ![]() ![]() |
HI:
Thank you for your help,but when i run it under release mode, FromHandle(pItem->GetHandle()); returns a point to another view but not the view i want
![]() |
|
![]() |
|
Oleg ![]() Senior Member ![]() Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
![]() ![]() ![]() ![]() ![]() |
Hi,
You do something wrong. Try to reproduce it with our Samples\ToolkitPro\TabbedView sample and send modifications.
|
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
![]() |
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 |