📄 cntritem.cpp
字号:
// cntritem.cpp : implementation of the CWingrepCntrItem class
//
#include "stdafx.h"
#include "wingrep.h"
#include "wingrdoc.h"
#include "cntritem.h"
#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CWingrepCntrItem implementation
IMPLEMENT_SERIAL(CWingrepCntrItem, COleClientItem, 0)
CWingrepCntrItem::CWingrepCntrItem(CWingrepDoc* pContainer)
: COleClientItem(pContainer)
{
m_rectPosition.SetRect(10, 10, 210, 210);
}
CWingrepCntrItem::~CWingrepCntrItem()
{
// TODO: add cleanup code here
}
void CWingrepCntrItem::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 CWingrepCntrItem::OnChangeItemPosition(const CRect& rectPos)
{
ASSERT_VALID(this);
CWingrepDoc* pDoc = GetDocument();
// During in-place activation CWingrepCntrItem::OnChangeItemPosition
// is called by the server to change the position on 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
pDoc->UpdateAllViews(NULL);
m_rectPosition = rectPos;
pDoc->SetModifiedFlag(TRUE);
return TRUE;
}
void CWingrepCntrItem::OnGetItemPosition(CRect& rPosition)
{
ASSERT_VALID(this);
// During in-place activation, CWingrepCntrItem::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 CWingrepCntrItem::GetActiveView.
// TODO: return correct rectangle (in pixels) in rectPos
//rPosition.SetRect(10, 10, 210, 210); Default hard-coded values
rPosition = m_rectPosition;
}
void CWingrepCntrItem::OnDeactivateUI(BOOL bUndoable)
{
COleClientItem::OnDeactivateUI(bUndoable);
// Close an in-place active item whenever it removes the user
// interface. The action here should match as closely as possible
// to the handling of the escape key in the view.
Deactivate(); // nothing fancy here -- just deactivate the object
}
void CWingrepCntrItem::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
// CWingrepCntrItem::GetDocument, it is a good idea to call
// the base class Serialize first.
COleClientItem::Serialize(ar);
// now store/retrieve data specific to CWingrepCntrItem
if (ar.IsStoring())
{
ar << m_rectPosition;
}
else
{
ar >> m_rectPosition;
}
}
/////////////////////////////////////////////////////////////////////////////
// CWingrepCntrItem diagnostics
#ifdef _DEBUG
void CWingrepCntrItem::AssertValid() const
{
COleClientItem::AssertValid();
}
void CWingrepCntrItem::Dump(CDumpContext& dc) const
{
COleClientItem::Dump(dc);
}
#endif
/////////////////////////////////////////////////////////////////////////////
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -