home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgLangD.iso / C++-7 / DISK8 / MFC / SAMPLES / OSERVER / BIBITEM.CP$ / bibitem
Encoding:
Text File  |  1992-03-17  |  2.1 KB  |  103 lines

  1. // This is a part of the Microsoft Foundation Classes C++ library.
  2. // Copyright (C) 1992 Microsoft Corporation
  3. // All rights reserved.
  4. //
  5. // This source code is only intended as a supplement to the
  6. // Microsoft Foundation Classes Reference and Microsoft
  7. // QuickHelp documentation provided with the library.
  8. // See these sources for detailed information regarding the
  9. // Microsoft Foundation Classes product.
  10.  
  11.  
  12. #include "bibref.h"
  13. #include "bibitem.h"
  14. #include "bibdoc.h"
  15.  
  16. /////////////////////////////////////////////////////////////////////////////
  17.  
  18. CBibItem::CBibItem(const char* pszKey)
  19. {
  20.     m_key = pszKey;     // used for the name of the item
  21. }
  22.  
  23. OLESTATUS
  24. CBibItem::OnRelease()
  25. {
  26.     OLESTATUS status;
  27.     if ((status = COleServerItem::OnRelease()) != OLE_OK)
  28.         return status;
  29.     delete this;
  30.     return OLE_OK;
  31. }
  32.  
  33. void
  34. CBibItem::Serialize(CArchive& ar)
  35. {
  36.     // the raw native format for a bib-item is just it's key
  37.  
  38.     if (ar.IsStoring())
  39.     {
  40.         ar << m_key;
  41.     }
  42.     else
  43.     {
  44.         ar >> m_key;
  45.     }
  46. }
  47.  
  48.  
  49. OLESTATUS
  50. CBibItem::OnShow(BOOL /* bTakeFocus */)
  51. {
  52.     // Scroll into view
  53.     if (!GetDocument()->ShowItem(m_key))
  54.     {
  55.         TRACE("no item specified\n");
  56.     }
  57.  
  58.     // make sure Bibref viewer is the topmost window
  59.     AfxGetApp()->m_pMainWnd->BringWindowToTop();
  60.  
  61.     return OLE_OK;
  62. }
  63.  
  64.  
  65. BOOL
  66. CBibItem::OnGetTextData(CString& rStringReturn)
  67. {
  68.     return GetDocument()->GetItemValue(m_key, rStringReturn) != -1;
  69. }
  70.  
  71. /////////////////////////////////////////////////////////////////////////////
  72. // Drawing items into bitmap or metafile
  73.  
  74. BOOL CBibItem::OnDraw(CMetaFileDC* pDC)
  75. {
  76.     CString value;
  77.  
  78.     if (GetDocument()->GetItemValue(m_key, value) == -1)
  79.         return TRUE;    // leave it blank
  80.     
  81.     pDC->SetMapMode(MM_TEXT);
  82.     pDC->TextOut(0, 0, value);
  83.     return TRUE;
  84. }
  85.  
  86. /////////////////////////////////////////////////////////////////////////////
  87.  
  88. #ifdef _DEBUG
  89. void CBibItem::AssertValid() const
  90. {
  91.     COleServerItem::AssertValid();
  92. }
  93.  
  94.  
  95. void CBibItem::Dump(CDumpContext& dc) const
  96. {
  97.     COleServerItem::Dump(dc);
  98. }
  99.  
  100. #endif
  101.  
  102. /////////////////////////////////////////////////////////////////////////////
  103.