home *** CD-ROM | disk | FTP | other *** search
/ Using Visual C++ 4 (Special Edition) / Using_Visual_C_4_Special_Edition_QUE_1996.iso / ch08 / oserver / srvritem.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1995-11-16  |  2.9 KB  |  106 lines

  1. // SrvrItem.cpp : implementation of the COServerSrvrItem class
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "OServer.h"
  6.  
  7. #include "OServerDoc.h"
  8. #include "SrvrItem.h"
  9.  
  10. #ifdef _DEBUG
  11. #define new DEBUG_NEW
  12. #undef THIS_FILE
  13. static char THIS_FILE[] = __FILE__;
  14. #endif
  15.  
  16. /////////////////////////////////////////////////////////////////////////////
  17. // COServerSrvrItem implementation
  18.  
  19. IMPLEMENT_DYNAMIC(COServerSrvrItem, COleServerItem)
  20.  
  21. COServerSrvrItem::COServerSrvrItem(COServerDoc* pContainerDoc)
  22.     : COleServerItem(pContainerDoc, TRUE)
  23. {
  24.     // TODO: add one-time construction code here
  25.     //  (eg, adding additional clipboard formats to the item's data source)
  26. }
  27.  
  28. COServerSrvrItem::~COServerSrvrItem()
  29. {
  30.     // TODO: add cleanup code here
  31. }
  32.  
  33. void COServerSrvrItem::Serialize(CArchive& ar)
  34. {
  35.     // COServerSrvrItem::Serialize will be called by the framework if
  36.     //  the item is copied to the clipboard.  This can happen automatically
  37.     //  through the OLE callback OnGetClipboardData.  A good default for
  38.     //  the embedded item is simply to delegate to the document's Serialize
  39.     //  function.  If you support links, then you will want to serialize
  40.     //  just a portion of the document.
  41.  
  42.     if (!IsLinkedItem())
  43.     {
  44.         COServerDoc* pDoc = GetDocument();
  45.         ASSERT_VALID(pDoc);
  46.         pDoc->Serialize(ar);
  47.     }
  48. }
  49.  
  50. BOOL COServerSrvrItem::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.     // COServerSrvrItem::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.     COServerDoc* pDoc = GetDocument();
  66.     ASSERT_VALID(pDoc);
  67.  
  68.     // TODO: replace this arbitrary size
  69.  
  70.     rSize = CSize(3000, 3000);   // 3000 x 3000 HIMETRIC units
  71.  
  72.     return TRUE;
  73. }
  74.  
  75. BOOL COServerSrvrItem::OnDraw(CDC* pDC, CSize& rSize)
  76. {
  77.     const CString kMessage = "Using Visual C++ 4.0, Special Edition";
  78.     COServerDoc* pDoc = GetDocument();
  79.     ASSERT_VALID(pDoc);
  80.  
  81.     pDC->SetMapMode(MM_ANISOTROPIC);
  82.     pDC->SetWindowOrg(0,0);
  83.     pDC->SetWindowExt(3000, 3000);
  84.     
  85.     pDC->TextOut(0, 0, kMessage, kMessage.GetLength());
  86.  
  87.     return TRUE;
  88. }
  89.  
  90. /////////////////////////////////////////////////////////////////////////////
  91. // COServerSrvrItem diagnostics
  92.  
  93. #ifdef _DEBUG
  94. void COServerSrvrItem::AssertValid() const
  95. {
  96.     COleServerItem::AssertValid();
  97. }
  98.  
  99. void COServerSrvrItem::Dump(CDumpContext& dc) const
  100. {
  101.     COleServerItem::Dump(dc);
  102. }
  103. #endif
  104.  
  105. /////////////////////////////////////////////////////////////////////////////
  106.