www.gusucode.com > 一些VC++网络编程实例源代码-源码程序 > 一些VC++网络编程实例源代码-源码程序\code\十三章\WebDraw\CntrItem.cpp
//Download by http://www.NewXing.com // CntrItem.cpp : implementation of the CWebDrawCntrItem class // #include "stdafx.h" #include "WebDraw.h" #include "WebDrawDoc.h" #include "WebDrawView.h" #include "CntrItem.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CWebDrawCntrItem implementation IMPLEMENT_SERIAL(CWebDrawCntrItem, COleDocObjectItem, 0) CWebDrawCntrItem::CWebDrawCntrItem(CWebDrawDoc* pContainer) : COleDocObjectItem(pContainer) { // TODO: add one-time construction code here } CWebDrawCntrItem::~CWebDrawCntrItem() { // TODO: add cleanup code here } void CWebDrawCntrItem::OnChange(OLE_NOTIFICATION nCode, DWORD dwParam) { ASSERT_VALID(this); COleDocObjectItem::OnChange(nCode, dwParam); // When an item is being edited (either in-place or fully open) // it sends OnChange notifications for changes in the state of the // item or visual appearance of its content. // TODO: invalidate the item by calling UpdateAllViews // (with hints appropriate to your application) GetDocument()->UpdateAllViews(NULL); // for now just update ALL views/no hints } BOOL CWebDrawCntrItem::OnChangeItemPosition(const CRect& rectPos) { ASSERT_VALID(this); // During in-place activation CWebDrawCntrItem::OnChangeItemPosition // is called by the server to change the position of the in-place // window. Usually, this is a result of the data in the server // document changing such that the extent has changed or as a result // of in-place resizing. // // The default here is to call the base class, which will call // COleDocObjectItem::SetItemRects to move the item // to the new position. if (!COleDocObjectItem::OnChangeItemPosition(rectPos)) return FALSE; // TODO: update any cache you may have of the item's rectangle/extent return TRUE; } void CWebDrawCntrItem::OnActivate() { } void CWebDrawCntrItem::OnDeactivateUI(BOOL bUndoable) { COleDocObjectItem::OnDeactivateUI(bUndoable); // Hide the object if it is not an outside-in object DWORD dwMisc = 0; m_lpObject->GetMiscStatus(GetDrawAspect(), &dwMisc); if (dwMisc & OLEMISC_INSIDEOUT) DoVerb(OLEIVERB_HIDE, NULL); } void CWebDrawCntrItem::Serialize(CArchive& ar) { ASSERT_VALID(this); // Call base class first to read in COleDocObjectItem data. // Since this sets up the m_pDocument pointer returned from // CWebDrawCntrItem::GetDocument, it is a good idea to call // the base class Serialize first. COleDocObjectItem::Serialize(ar); // now store/retrieve data specific to CWebDrawCntrItem if (ar.IsStoring()) { // TODO: add storing code here } else { // TODO: add loading code here } } BOOL CWebDrawCntrItem::CanActivate() { // Editing in-place while the server itself is being edited in-place // does not work and is not supported. So, disable in-place // activation in this case. CWebDrawDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); ASSERT(pDoc->IsKindOf(RUNTIME_CLASS(COleServerDoc))); if (pDoc->IsInPlaceActive()) return FALSE; // otherwise, rely on default behavior return COleClientItem::CanActivate(); } ///////////////////////////////////////////////////////////////////////////// // CWebDrawCntrItem diagnostics #ifdef _DEBUG void CWebDrawCntrItem::AssertValid() const { COleDocObjectItem::AssertValid(); } void CWebDrawCntrItem::Dump(CDumpContext& dc) const { COleDocObjectItem::Dump(dc); } #endif /////////////////////////////////////////////////////////////////////////////