How can I insert and remove worksheets at runtime?

Here is some self-explaining sample code:

void CMyGridView::OnUpdateEditInsertsheet(CCmdUI* pCmdUI) 
{
   CGXTabWnd* pTabWnd = GetParentTabWnd(this, TRUE);
   pCmdUI->Enable(pTabWnd != NULL);
}
void CMyGridView::OnEditInsertsheet() 
{
   CGXTabWnd* pTabWnd = GetParentTabWnd(this, TRUE);
   if (pTabWnd)
   {
      pTabWnd->CreateView(RUNTIME_CLASS(CMyGridView), _T("New"), NULL);
      pTabWnd->SwitchTab(pTabWnd->GetBeam().GetCount()-1);
   }
}
void CMyGridView::OnEditRemovesheet() 
{
   CGXTabWnd* pTabWnd = GetParentTabWnd(this, TRUE);
   if (pTabWnd && pTabWnd->GetBeam().GetCount() > 0)
      pTabWnd->RemoveTab(this);
}
void CMyGridView::OnUpdateEditRemovesheet(CCmdUI* pCmdUI) 
{
   CGXTabWnd* pTabWnd = GetParentTabWnd(this, TRUE);
   pCmdUI->Enable(pTabWnd && pTabWnd->GetBeam().GetCount() > 0);
}