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

📄 cntritem.cpp

📁 vc++net很不错的一个工具
💻 CPP
字号:
// CntrItem.cpp : CExampleCntrItem 类的实现
//
#include "stdafx.h"
#include "Example.h"
#include "ExampleDoc.h"
#include "ExampleView.h"
#include "CntrItem.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif

// CExampleCntrItem 的实现
IMPLEMENT_SERIAL(CExampleCntrItem, COleClientItem, 0)
CExampleCntrItem::CExampleCntrItem(CExampleDoc* pContainer)
	: COleClientItem(pContainer)
{
	// TODO:在此添加一次性构造代码
	m_rect.SetRect(50,50,250,250);
}

CExampleCntrItem::~CExampleCntrItem()
{
	// TODO: 在此处添加清除代码
}

void CExampleCntrItem::OnChange(OLE_NOTIFICATION nCode, DWORD dwParam)
{
	ASSERT_VALID(this);
	COleClientItem::OnChange(nCode, dwParam);
	GetDocument()->UpdateAllViews(NULL);
}

BOOL CExampleCntrItem::OnChangeItemPosition(const CRect& rectPos)
{
	ASSERT_VALID(this);
	if (!COleClientItem::OnChangeItemPosition(rectPos))
		return FALSE;
	// TODO:更新您在该项的矩形/范围内可具有的任何缓存
	m_rect=rectPos;
	GetDocument()->SetModifiedFlag();
	GetDocument()->UpdateAllViews(NULL);
	return TRUE;
}

void CExampleCntrItem::OnGetItemPosition(CRect& rPosition)
{
	ASSERT_VALID(this);
	// TODO:返回 rPosition 中的正确矩形(以像素表示)
	rPosition=m_rect;
	return;
}

void CExampleCntrItem::OnActivate()
{
	// 每个框架只能有一个就地激活项
	CExampleView* pView = GetActiveView();
	ASSERT_VALID(pView);
	COleClientItem* pItem = GetDocument()->GetInPlaceActiveItem(pView);
	if (pItem != NULL && pItem != this)
		pItem->Close();

	COleClientItem::OnActivate();
}

void CExampleCntrItem::OnDeactivateUI(BOOL bUndoable)
{
	COleClientItem::OnDeactivateUI(bUndoable);

    DWORD dwMisc = 0;
    m_lpObject->GetMiscStatus(GetDrawAspect(), &dwMisc);
    if (dwMisc & OLEMISC_INSIDEOUT)
        DoVerb(OLEIVERB_HIDE, NULL);
}

void CExampleCntrItem::Serialize(CArchive& ar)
{
	ASSERT_VALID(this);
	COleClientItem::Serialize(ar);
	// 现在存储/检索特定于 CExampleCntrItem 的数据
	if (ar.IsStoring())
	{
		// TODO:在此添加存储代码
		ar<<m_rect;
	}
	else
	{
		// TODO:在此添加加载代码
		ar>>m_rect;
	}
}

⌨️ 快捷键说明

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