srvritem.cpp
上传用户:szled88
上传日期:2015-04-09
资源大小:43957k
文件大小:4k
- // [!output SERVER_ITEM_IMPL] : implementation of the [!output SERVER_ITEM_CLASS] class
- //
- #include "stdafx.h"
- #include "[!output APP_HEADER]"
- #include "[!output DOC_HEADER]"
- #include "[!output SERVER_ITEM_HEADER]"
- [!if CONTAINER_SERVER]
- #include "[!output CONTAINER_ITEM_HEADER]"
- [!endif]
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #endif
- // [!output SERVER_ITEM_CLASS] implementation
- IMPLEMENT_DYNAMIC([!output SERVER_ITEM_CLASS], [!output SERVER_ITEM_BASE_CLASS])
- [!output SERVER_ITEM_CLASS]::[!output SERVER_ITEM_CLASS]([!output DOC_CLASS]* pContainerDoc)
- : [!output SERVER_ITEM_BASE_CLASS](pContainerDoc, TRUE)
- {
- // TODO: add one-time construction code here
- // (eg, adding additional clipboard formats to the item's data source)
- }
- [!output SERVER_ITEM_CLASS]::~[!output SERVER_ITEM_CLASS]()
- {
- // TODO: add cleanup code here
- }
- void [!output SERVER_ITEM_CLASS]::Serialize(CArchive& ar)
- {
- // [!output SERVER_ITEM_CLASS]::Serialize will be called by the framework if
- // the item is copied to the clipboard. This can happen automatically
- // through the OLE callback OnGetClipboardData. A good default for
- // the embedded item is simply to delegate to the document's Serialize
- // function. If you support links, then you will want to serialize
- // just a portion of the document.
- if (!IsLinkedItem())
- {
- [!output DOC_CLASS]* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
- if (pDoc)
- pDoc->Serialize(ar);
- }
- }
- BOOL [!output SERVER_ITEM_CLASS]::OnGetExtent(DVASPECT dwDrawAspect, CSize& rSize)
- {
- // Most applications, like this one, only handle drawing the content
- // aspect of the item. If you wish to support other aspects, such
- // as DVASPECT_THUMBNAIL (by overriding OnDrawEx), then this
- // implementation of OnGetExtent should be modified to handle the
- // additional aspect(s).
- if (dwDrawAspect != DVASPECT_CONTENT)
- return [!output SERVER_ITEM_BASE_CLASS]::OnGetExtent(dwDrawAspect, rSize);
- // [!output SERVER_ITEM_CLASS]::OnGetExtent is called to get the extent in
- // HIMETRIC units of the entire item. The default implementation
- // here simply returns a hard-coded number of units.
- // TODO: replace this arbitrary size
- rSize = CSize(3000, 3000); // 3000 x 3000 HIMETRIC units
- return TRUE;
- }
- BOOL [!output SERVER_ITEM_CLASS]::OnDraw(CDC* pDC, CSize& rSize)
- {
- if (!pDC)
- return FALSE;
- // Remove this if you use rSize
- UNREFERENCED_PARAMETER(rSize);
- // TODO: set mapping mode and extent
- // (The extent is usually the same as the size returned from OnGetExtent)
- pDC->SetMapMode(MM_ANISOTROPIC);
- pDC->SetWindowOrg(0,0);
- pDC->SetWindowExt(3000, 3000);
- // TODO: add drawing code here. Optionally, fill in the HIMETRIC extent.
- // All drawing takes place in the metafile device context (pDC).
- [!if CONTAINER_SERVER]
- // TODO: also draw embedded [!output CONTAINER_ITEM_CLASS] objects.
- [!endif]
- [!if CONTAINER_SERVER]
- // The following code draws the first item at an arbitrary position.
- // TODO: remove this code when your real drawing code is complete
- [!output DOC_CLASS]* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
- if (!pDoc)
- return FALSE;
- POSITION pos = pDoc->GetStartPosition();
- [!output CONTAINER_ITEM_CLASS]* pItem = DYNAMIC_DOWNCAST([!output CONTAINER_ITEM_CLASS], pDoc->GetNextClientItem(pos));
- if (pItem != NULL)
- pItem->Draw(pDC, CRect(10, 10, 1010, 1010));
- [!endif]
- return TRUE;
- }
- // [!output SERVER_ITEM_CLASS] diagnostics
- #ifdef _DEBUG
- void [!output SERVER_ITEM_CLASS]::AssertValid() const
- {
- [!output SERVER_ITEM_BASE_CLASS]::AssertValid();
- }
- void [!output SERVER_ITEM_CLASS]::Dump(CDumpContext& dc) const
- {
- [!output SERVER_ITEM_BASE_CLASS]::Dump(dc);
- }
- #endif