Print Page | Close Window

A Question About the Tab Control

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=11653
Printed Date: 14 September 2025 at 11:01pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: A Question About the Tab Control
Posted By: fireflame
Subject: A Question About the Tab Control
Date 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?



Replies:
Posted By: Oleg
Date Posted: 30 July 2008 at 7:41am
Hi,
Instead GetData call CWnd::FromHandle(pItem->GetHandle());


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: fireflame
Date Posted: 30 July 2008 at 10:22pm
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


Posted By: Oleg
Date Posted: 31 July 2008 at 1:44am
Hi,
 
You do something wrong. Try to reproduce it with our Samples\ToolkitPro\TabbedView sample   and send modifications.


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net