void CDiscoverMDIView::OnInsertObject()
{
	// Invoke the standard Insert Object dialog box to obtain information
	//  for new CDiscoverMDICntrItem object.
	COleInsertDialog dlg;
	if (dlg.DoModal() != IDOK)
		return;

	BeginWaitCursor();

	CDiscoverMDICntrItem* pItem = NULL;
	TRY
	{
		// Create new item connected to this document.
		CDiscoverMDIDoc* pDoc = GetDocument();
		ASSERT_VALID(pDoc);
		pItem = new CDiscoverMDICntrItem(pDoc);
		ASSERT_VALID(pItem);

		// Initialize the item from the dialog data.
		if (!dlg.CreateItem(pItem))
			AfxThrowMemoryException();  // any exception will do
		ASSERT_VALID(pItem);

		// If item created from class list (not from file) then launch
		//  the server to edit the item.
		if (dlg.GetSelectionType() == COleInsertDialog::createNewItem)
			pItem->DoVerb(OLEIVERB_SHOW, this);

		ASSERT_VALID(pItem);

		// As an arbitrary user interface design, this sets the selection
		//  to the last item inserted.

		// TODO: reimplement selection as appropriate for your application

		m_pSelection = pItem;   // set selection to last inserted item
		pDoc->UpdateAllViews(NULL);
	}
	CATCH(CException, e)
	{
		if (pItem != NULL)
		{
			ASSERT_VALID(pItem);
			pItem->Delete();
		}
		AfxMessageBox(IDP_FAILED_TO_CREATE);
	}
	END_CATCH

	EndWaitCursor();
}
Example #2
0
void CDrawView::OnInsertObject()
{
	// Invoke the standard Insert Object dialog box to obtain information
	//  for new CDrawItem object.
	COleInsertDialog dlg;
	if (dlg.DoModal() != IDOK)
		return;

	BeginWaitCursor();

	// First create the C++ object
	CDrawOleObj* pObj = new CDrawOleObj(GetInitialPosition());
	ASSERT_VALID(pObj);
	CDrawItem* pItem = new CDrawItem(GetDocument(), pObj);
	ASSERT_VALID(pItem);
	pObj->m_pClientItem = pItem;

	// Now create the OLE object/item
	TRY
	{
		if (!dlg.CreateItem(pObj->m_pClientItem))
			AfxThrowMemoryException();

		// add the object to the document
		/*GetDocument()->*/g_pGuiManager->AddBack(pObj);
		pObj->m_pDocument = GetDocument();
		GetDocument()->SetModifiedFlag();

		// try to get initial presentation data
		pItem->UpdateLink();
		pItem->UpdateExtent();

		// if insert new object -- initially show the object
		if (dlg.GetSelectionType() == COleInsertDialog::createNewItem)
			pItem->DoVerb(OLEIVERB_SHOW, this);
	}
	CATCH_ALL(e)
	{
		// clean up item
		pItem->Delete();
		pObj->m_pClientItem = NULL;
		/*GetDocument()->*/g_pGuiManager->Remove(pObj);
		GetDocument()->SetModifiedFlag(TRUE);
		pObj->Remove();

		AfxMessageBox(IDP_FAILED_TO_CREATE);
	}
	END_CATCH_ALL

	EndWaitCursor();
}
Example #3
0
void CClientView::OnInsertObject()
{
	// 调用标准的“插入对象”对话框以获得有关
	//  新 CClientCntrItem 对象的信息
	COleInsertDialog dlg;
	if (dlg.DoModal(COleInsertDialog::DocObjectsOnly) != IDOK)
		return;

	BeginWaitCursor();

	CClientCntrItem* pItem = NULL;
	TRY
	{
		// 创建与此文档相连接的新项
		CClientDoc* pDoc = GetDocument();
		ASSERT_VALID(pDoc);
		pItem = new CClientCntrItem(pDoc);
		ASSERT_VALID(pItem);

		// 通过对话框数据初始化该项
		if (!dlg.CreateItem(pItem))
			AfxThrowMemoryException();  // 任何异常都将导致该结果
		ASSERT_VALID(pItem);
		
		pItem->DoVerb(OLEIVERB_SHOW, this);

		ASSERT_VALID(pItem);
		// 作为任意用户界面设计,这会将选定内容
		//  设置为插入的最后一项

		// TODO: 重新实现选定内容,使其适合于您的应用程序
		m_pSelection = pItem;   // 将选定内容设置为插入的最后一项
		pDoc->UpdateAllViews(NULL);
	}
	CATCH(CException, e)
	{
		if (pItem != NULL)
		{
			ASSERT_VALID(pItem);
			pItem->Delete();
		}
		AfxMessageBox(IDP_FAILED_TO_CREATE);
	}
	END_CATCH

	EndWaitCursor();
}
void CABMOfficeSystemcppView::OnInsertObject()
{
	// Invoke the standard Insert Object dialog box to obtain information
	//  for new CABMOfficeSystemcppCntrItem object
	COleInsertDialog dlg;
	if (dlg.DoModal(COleInsertDialog::DocObjectsOnly) != IDOK)
		return;

	BeginWaitCursor();

	CABMOfficeSystemcppCntrItem* pItem = NULL;
	TRY
	{
		// Create new item connected to this document
		CABMOfficeSystemcppDoc* pDoc = GetDocument();
		ASSERT_VALID(pDoc);
		pItem = new CABMOfficeSystemcppCntrItem(pDoc);
		ASSERT_VALID(pItem);

		// Initialize the item from the dialog data
		if (!dlg.CreateItem(pItem))
			AfxThrowMemoryException();  // any exception will do
		ASSERT_VALID(pItem);
		
		pItem->DoVerb(OLEIVERB_SHOW, this);

		ASSERT_VALID(pItem);
		// As an arbitrary user interface design, this sets the selection
		//  to the last item inserted

		// TODO: reimplement selection as appropriate for your application
		m_pSelection = pItem;   // set selection to last inserted item
		pDoc->UpdateAllViews(NULL);
	}
	CATCH(CException, e)
	{
		if (pItem != NULL)
		{
			ASSERT_VALID(pItem);
			pItem->Delete();
		}
		AfxMessageBox(IDP_FAILED_TO_CREATE);
	}
	END_CATCH

	EndWaitCursor();
}
Example #5
0
void CEx27bView::OnEditInsertobject() 
{
	CEx27bDoc* pDoc = GetDocument();
	COleInsertDialog dlg;
	if( dlg.DoModal() == IDCANCEL) return;
    // no addrefs done for GetInterface
	LPOLECLIENTSITE pClientSite =
				(LPOLECLIENTSITE) pDoc->GetInterface(&IID_IOleClientSite);
	ASSERT(pClientSite != NULL);
	pDoc->DeleteContents();
	VERIFY(::OleCreate(dlg.GetClassID(), IID_IOleObject, 
		   OLERENDER_DRAW, NULL, pClientSite, pDoc->m_pTempStgSub, 
		   (void**) &pDoc->m_lpOleObj) == S_OK);
	SetViewAdvise();

	pDoc->m_lpOleObj->DoVerb(OLEIVERB_SHOW, NULL, pClientSite, 0, 
		NULL, NULL); // OleRun doesn´t show it
	SetNames();
	GetDocument()->SetModifiedFlag();
	GetSize();
	pDoc->UpdateAllViews(NULL);
}