home *** CD-ROM | disk | FTP | other *** search
- // CntrItem.cpp : implementation of the CContainerMFCCntrItem class
- //
- // This is a part of the Microsoft Foundation Classes C++ library.
- // Copyright (C) 1992-1998 Microsoft Corporation
- // All rights reserved.
- //
- // This source code is only intended as a supplement to the
- // Microsoft Foundation Classes Reference and related
- // electronic documentation provided with the library.
- // See these sources for detailed information regarding the
- // Microsoft Foundation Classes product.
-
-
- #include "stdafx.h"
- #include "containerMFC.h"
-
- #include "containerMFCDoc.h"
- #include "containerMFCView.h"
- #include "CntrItem.h"
-
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
-
- /////////////////////////////////////////////////////////////////////////////
- // CContainerMFCCntrItem implementation
-
- IMPLEMENT_SERIAL(CContainerMFCCntrItem, COleClientItem, 0)
-
- CContainerMFCCntrItem::CContainerMFCCntrItem(CContainerMFCDoc* pContainer)
- : COleClientItem(pContainer)
- {
- // TODO: add one-time construction code here
-
- }
-
- CContainerMFCCntrItem::~CContainerMFCCntrItem()
- {
- // TODO: add cleanup code here
-
- }
-
- void CContainerMFCCntrItem::OnChange(OLE_NOTIFICATION nCode, DWORD dwParam)
- {
- ASSERT_VALID(this);
-
- COleClientItem::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 CContainerMFCCntrItem::OnChangeItemPosition(const CRect& rectPos)
- {
- ASSERT_VALID(this);
-
- // During in-place activation CContainerMFCCntrItem::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
- // COleClientItem::SetItemRects to move the item
- // to the new position.
-
- if (!COleClientItem::OnChangeItemPosition(rectPos))
- return FALSE;
-
- // TODO: update any cache you may have of the item's rectangle/extent
-
- return TRUE;
- }
-
- void CContainerMFCCntrItem::OnGetItemPosition(CRect& rPosition)
- {
- ASSERT_VALID(this);
-
- // During in-place activation, CContainerMFCCntrItem::OnGetItemPosition
- // will be called to determine the location of this item. The default
- // implementation created from AppWizard simply returns a hard-coded
- // rectangle. Usually, this rectangle would reflect the current
- // position of the item relative to the view used for activation.
- // You can obtain the view by calling CContainerMFCCntrItem::GetActiveView.
-
- CRect r;
- GetActiveView()->GetClientRect(&r);
- rPosition = r;
- }
-
- void CContainerMFCCntrItem::OnActivate()
- {
- // Allow only one inplace activate item per frame
- CContainerMFCView* pView = GetActiveView();
- ASSERT_VALID(pView);
- COleClientItem* pItem = GetDocument()->GetInPlaceActiveItem(pView);
- if (pItem != NULL && pItem != this)
- pItem->Close();
-
- COleClientItem::OnActivate();
- }
-
- void CContainerMFCCntrItem::OnDeactivateUI(BOOL bUndoable)
- {
- COleClientItem::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 CContainerMFCCntrItem::Serialize(CArchive& ar)
- {
- ASSERT_VALID(this);
-
- // Call base class first to read in COleClientItem data.
- // Since this sets up the m_pDocument pointer returned from
- // CContainerMFCCntrItem::GetDocument, it is a good idea to call
- // the base class Serialize first.
- COleClientItem::Serialize(ar);
-
- // now store/retrieve data specific to CContainerMFCCntrItem
- if (ar.IsStoring())
- {
- // TODO: add storing code here
- }
- else
- {
- // TODO: add loading code here
- }
- }
-
- /////////////////////////////////////////////////////////////////////////////
- // CContainerMFCCntrItem diagnostics
-
- #ifdef _DEBUG
- void CContainerMFCCntrItem::AssertValid() const
- {
- COleClientItem::AssertValid();
- }
-
- void CContainerMFCCntrItem::Dump(CDumpContext& dc) const
- {
- COleClientItem::Dump(dc);
- }
- #endif
-
- /////////////////////////////////////////////////////////////////////////////
-