⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cntritem.cpp

📁 支持在线编辑的活动文档控件
💻 CPP
字号:
// CntrItem.cpp : implementation of the CKyOfficeCntrItem class
//

#include "stdafx.h"
#include "KyOffice.h"

#include "KyOfficeDoc.h"
#include "KyOfficeView.h"
#include "CntrItem.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CKyOfficeCntrItem implementation

IMPLEMENT_SERIAL(CKyOfficeCntrItem, COleDocObjectItem, 0)

CKyOfficeCntrItem::CKyOfficeCntrItem(CKyOfficeDoc* pContainer)
	: COleDocObjectItem(pContainer)
{
	// TODO: add one-time construction code here
	
}

CKyOfficeCntrItem::~CKyOfficeCntrItem()
{
	// TODO: add cleanup code here
	
}

void CKyOfficeCntrItem::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 CKyOfficeCntrItem::OnChangeItemPosition(const CRect& rectPos)
{
	ASSERT_VALID(this);

	// During in-place activation CKyOfficeCntrItem::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 CKyOfficeCntrItem::OnGetItemPosition(CRect& rPosition)
{
	ASSERT_VALID(this);

	// During in-place activation, CKyOfficeCntrItem::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 CKyOfficeCntrItem::GetActiveView.

	// TODO: return correct rectangle (in pixels) in rPosition

	//rPosition.SetRect(10, 10, 210, 210);
	m_pView->GetClientRect(rPosition);
}

void CKyOfficeCntrItem::OnActivate()
{
    // Allow only one inplace activate item per frame
	CDocument * pDocument = GetDocument();
	ASSERT_VALID(pDocument);

	POSITION pos = pDocument->GetFirstViewPosition();
	while(pos)
	{
		CView * pView = pDocument->GetNextView(pos);
		ASSERT_VALID(pView);

		COleDocObjectItem* pItem = (COleDocObjectItem*) GetDocument()->GetInPlaceActiveItem(pView);
		if (pItem != NULL && pItem != this)
			pItem->Close();
	}
    
    COleDocObjectItem::OnActivate();
}

void CKyOfficeCntrItem::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 CKyOfficeCntrItem::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
	//  CKyOfficeCntrItem::GetDocument, it is a good idea to call
	//  the base class Serialize first.
	COleDocObjectItem::Serialize(ar);

	// now store/retrieve data specific to CKyOfficeCntrItem
	if (ar.IsStoring())
	{
		// TODO: add storing code here
	}
	else
	{
		// TODO: add loading code here
	}
}

/////////////////////////////////////////////////////////////////////////////
// CKyOfficeCntrItem diagnostics

#ifdef _DEBUG
void CKyOfficeCntrItem::AssertValid() const
{
	COleDocObjectItem::AssertValid();
}

void CKyOfficeCntrItem::Dump(CDumpContext& dc) const
{
	COleDocObjectItem::Dump(dc);
}
#endif

/////////////////////////////////////////////////////////////////////////////
void CKyOfficeCntrItem::OnInsertMenus(CMenu* pMenuShared, LPOLEMENUGROUPWIDTHS lpMenuWidths)
{
	COleDocObjectItem::OnInsertMenus(pMenuShared, lpMenuWidths);
}

void CKyOfficeCntrItem::OnSetMenu(CMenu* pMenuShared, HOLEMENU holemenu, HWND hwndActiveObject)
{
	COleDocObjectItem::OnSetMenu(pMenuShared, holemenu, hwndActiveObject);
}

void CKyOfficeCntrItem::OnRemoveMenus(CMenu *pMenuShared)
{
	COleClientItem::OnRemoveMenus(pMenuShared);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -