source: trunk/MFCtooling/TestProg/SrvrItem.cpp @ 1237

Last change on this file since 1237 was 32, checked in by sherbold, 14 years ago
File size: 3.2 KB
Line 
1// SrvrItem.cpp : implementation of the CTestProgSrvrItem class
2//
3
4#include "stdafx.h"
5#include "TestProg.h"
6
7#include "TestProgDoc.h"
8#include "SrvrItem.h"
9#include "CntrItem.h"
10
11#ifdef _DEBUG
12#define new DEBUG_NEW
13#endif
14
15
16// CTestProgSrvrItem implementation
17
18IMPLEMENT_DYNAMIC(CTestProgSrvrItem, COleServerItem)
19
20CTestProgSrvrItem::CTestProgSrvrItem(CTestProgDoc* pContainerDoc)
21        : COleServerItem(pContainerDoc, TRUE)
22{
23        // TODO: add one-time construction code here
24        //  (eg, adding additional clipboard formats to the item's data source)
25}
26
27CTestProgSrvrItem::~CTestProgSrvrItem()
28{
29        // TODO: add cleanup code here
30}
31
32void CTestProgSrvrItem::Serialize(CArchive& ar)
33{
34        // CTestProgSrvrItem::Serialize will be called by the framework if
35        //  the item is copied to the clipboard.  This can happen automatically
36        //  through the OLE callback OnGetClipboardData.  A good default for
37        //  the embedded item is simply to delegate to the document's Serialize
38        //  function.  If you support links, then you will want to serialize
39        //  just a portion of the document.
40
41        if (!IsLinkedItem())
42        {
43                CTestProgDoc* pDoc = GetDocument();
44                ASSERT_VALID(pDoc);
45                if (pDoc)
46                        pDoc->Serialize(ar);
47        }
48}
49
50BOOL CTestProgSrvrItem::OnGetExtent(DVASPECT dwDrawAspect, CSize& rSize)
51{
52        // Most applications, like this one, only handle drawing the content
53        //  aspect of the item.  If you wish to support other aspects, such
54        //  as DVASPECT_THUMBNAIL (by overriding OnDrawEx), then this
55        //  implementation of OnGetExtent should be modified to handle the
56        //  additional aspect(s).
57
58        if (dwDrawAspect != DVASPECT_CONTENT)
59                return COleServerItem::OnGetExtent(dwDrawAspect, rSize);
60
61        // CTestProgSrvrItem::OnGetExtent is called to get the extent in
62        //  HIMETRIC units of the entire item.  The default implementation
63        //  here simply returns a hard-coded number of units.
64
65        // TODO: replace this arbitrary size
66
67        rSize = CSize(3000, 3000);   // 3000 x 3000 HIMETRIC units
68
69        return TRUE;
70}
71
72BOOL CTestProgSrvrItem::OnDraw(CDC* pDC, CSize& rSize)
73{
74        if (!pDC)
75                return FALSE;
76
77        // Remove this if you use rSize
78        UNREFERENCED_PARAMETER(rSize);
79
80        // TODO: set mapping mode and extent
81        //  (The extent is usually the same as the size returned from OnGetExtent)
82        pDC->SetMapMode(MM_ANISOTROPIC);
83        pDC->SetWindowOrg(0,0);
84        pDC->SetWindowExt(3000, 3000);
85
86        // TODO: add drawing code here.  Optionally, fill in the HIMETRIC extent.
87        //  All drawing takes place in the metafile device context (pDC).
88
89        // TODO: also draw embedded CTestProgCntrItem objects.
90
91        // The following code draws the first item at an arbitrary position.
92
93        // TODO: remove this code when your real drawing code is complete
94
95        CTestProgDoc* pDoc = GetDocument();
96        ASSERT_VALID(pDoc);
97        if (!pDoc)
98                return FALSE;
99
100        POSITION pos = pDoc->GetStartPosition();
101        CTestProgCntrItem* pItem = DYNAMIC_DOWNCAST(CTestProgCntrItem, pDoc->GetNextClientItem(pos));
102        if (pItem != NULL)
103                pItem->Draw(pDC, CRect(10, 10, 1010, 1010));
104        return TRUE;
105}
106
107
108// CTestProgSrvrItem diagnostics
109
110#ifdef _DEBUG
111void CTestProgSrvrItem::AssertValid() const
112{
113        COleServerItem::AssertValid();
114}
115
116void CTestProgSrvrItem::Dump(CDumpContext& dc) const
117{
118        COleServerItem::Dump(dc);
119}
120#endif
121
Note: See TracBrowser for help on using the repository browser.