Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - A Question About the Tab Control
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

A Question About the Tab Control

 Post Reply Post Reply
Author
Message
fireflame View Drop Down
Groupie
Groupie


Joined: 15 March 2007
Status: Offline
Points: 21
Post Options Post Options   Thanks (0) Thanks(0)   Quote fireflame Quote  Post ReplyReply Direct Link To This Post Topic: A Question About the Tab Control
    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?
Back to Top
Oleg View Drop Down
Senior Member
Senior Member


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 30 July 2008 at 7:41am
Hi,
Instead GetData call CWnd::FromHandle(pItem->GetHandle());
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
fireflame View Drop Down
Groupie
Groupie


Joined: 15 March 2007
Status: Offline
Points: 21
Post Options Post Options   Thanks (0) Thanks(0)   Quote fireflame Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
Oleg View Drop Down
Senior Member
Senior Member


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.047 seconds.