home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / mfc / database / daoctl / accspict / accsctl.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-03-27  |  4.2 KB  |  143 lines

  1. // AccsCtl.h : Declaration of the CAccessPictCtrl OLE control class.
  2. //
  3. // This is a part of the Microsoft Foundation Classes C++ library.
  4. // Copyright (C) 1992-1998 Microsoft Corporation
  5. // All rights reserved.
  6. //
  7. // This source code is only intended as a supplement to the
  8. // Microsoft Foundation Classes Reference and related
  9. // electronic documentation provided with the library.
  10. // See these sources for detailed information regarding the
  11. // Microsoft Foundation Classes product.
  12.  
  13.  
  14. /////////////////////////////////////////////////////////////////////////////
  15. // struct OLEOBJECTHEADER : Access Object Header Structure
  16.  
  17. struct OLEOBJECTHEADER
  18. {
  19.     WORD typ;       // Type signature (0x1C15)
  20.     WORD cbHdr;     // sizeof(struct OLEOBJECTHEADER) + cchName + cchClass
  21.     LONG lobjType;  // OLE Object Type Code (OT_STATIC, OT_LINKED, OT_EMBEDDED)
  22.     WORD cchName;   // Count of characters in object Name (CchSz(szName) + 1))
  23.     WORD cchClass;  // Count of characters in class Name (CchSz(szClss) + 1))
  24.     WORD ibName;    // Offset of object name in structure (sizeof(OLEOBJECTHEADER)
  25.     WORD ibClass;   // Offset of class name in structure (ibName + cchName)
  26.     POINTS ptSize;  // Original size of Object (MM_HIMETRIC)
  27. };
  28.  
  29.  
  30. /////////////////////////////////////////////////////////////////////////////
  31. // struct OLE1STREAM : OLESTREAM struct w/ knowledge of the Access data
  32.  
  33. typedef struct
  34. {
  35.     LPOLESTREAMVTBL pvt;        // OLESTREAMVTBL pointer
  36.     LPBYTE          lpData;     // Link to Data in .MDB file
  37.     DWORD           dwSize;     // OLESTREAM length (relative to position)
  38. } OLE1STREAM, FAR* LPOLE1STREAM;
  39.  
  40.  
  41. /////////////////////////////////////////////////////////////////////////////
  42. // OLESTREAMVTBL Get and Put callback functions
  43.  
  44. DWORD FAR PASCAL Get(LPOLESTREAM pstm, void FAR* pb, DWORD cb);
  45. DWORD FAR PASCAL Put(LPOLESTREAM pstm, const void FAR* pb, DWORD cb);
  46.  
  47. /////////////////////////////////////////////////////////////////////////////
  48. // CAccessPictCtrl : See AccsCtl.cpp for implementation.
  49.  
  50. class CAccessPictCtrl : public COleControl
  51. {
  52.     DECLARE_DYNCREATE(CAccessPictCtrl)
  53.  
  54. // Constructor
  55. public:
  56.     CAccessPictCtrl();
  57.  
  58. // Overrides
  59.  
  60.     // Drawing function
  61.     virtual void OnDraw(
  62.                 CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid);
  63.  
  64.     // Persistence
  65.     virtual void DoPropExchange(CPropExchange* pPX);
  66.  
  67.     // Reset control state
  68.     virtual void OnResetState();
  69.  
  70. // Attributes
  71. protected:
  72.     CRect CalcRectSize();
  73.     // Attributes of Access Object
  74.     BOOL            m_bIsObject;
  75.     CStreamDib      m_StreamDib;
  76.     CSize           m_size;
  77.  
  78.     CPictureHolder  m_Pict;
  79.     BOOL            m_bPictLoaded;
  80.  
  81. // Implementation
  82. protected:
  83.     // State Cleanup Function
  84.     void ResetState();
  85.  
  86.     // Drawing Helper
  87.     CRect CalcRectSize(const CRect& rect);
  88.  
  89.     ~CAccessPictCtrl();
  90.  
  91.     DECLARE_OLECREATE_EX(CAccessPictCtrl)    // Class factory and guid
  92.     DECLARE_OLETYPELIB(CAccessPictCtrl)      // GetTypeInfo
  93.     DECLARE_PROPPAGEIDS(CAccessPictCtrl)     // Property page IDs
  94.     DECLARE_OLECTLTYPE(CAccessPictCtrl)      // Type name and misc status
  95.  
  96.     // Data Read Functions
  97.     BOOL ReadObject(SAFEARRAY FAR* psaObject);
  98.     LPSTORAGE ReadObjectHeader(SAFEARRAY FAR* psaObject);
  99.     BOOL ReadObjectData(LPSTREAM lpStream);
  100.  
  101.     // OLESTREAM Function Helpers
  102.     LPOLE1STREAM    CreateOleStream(LPBYTE lpData, DWORD dwSize);
  103.     void            DeleteOleStream(LPOLE1STREAM pStream);
  104.     DWORD           GetStreamSize(SAFEARRAY FAR* psaObject, DWORD dwOffset);
  105.  
  106.  
  107. // Message maps
  108.     //{{AFX_MSG(CAccessPictCtrl)
  109.         // NOTE - ClassWizard will add and remove member functions here.
  110.         //    DO NOT EDIT what you see in these blocks of generated code !
  111.     //}}AFX_MSG
  112.     DECLARE_MESSAGE_MAP()
  113.  
  114. // Dispatch maps
  115.     //{{AFX_DISPATCH(CAccessPictCtrl)
  116.     BOOL m_bStretch;
  117.     BOOL m_bPreserveRatio;
  118.     afx_msg BOOL GetIsAccessObject();
  119.     afx_msg LPPICTUREDISP GetPicture();
  120.     afx_msg BOOL SetData(VARIANT FAR* pvarData);
  121.     //}}AFX_DISPATCH
  122.     DECLARE_DISPATCH_MAP()
  123.  
  124.     afx_msg void AboutBox();
  125.  
  126. // Event maps
  127.     //{{AFX_EVENT(CAccessPictCtrl)
  128.     //}}AFX_EVENT
  129.     DECLARE_EVENT_MAP()
  130.  
  131. // Dispatch and event IDs
  132. public:
  133.     enum {
  134.     //{{AFX_DISP_ID(CAccessPictCtrl)
  135.     dispidIsAccessObject = 3L,
  136.     dispidStretchToFit = 1L,
  137.     dispidPreserveRatio = 2L,
  138.     dispidPicture = 4L,
  139.     dispidSetData = 5L,
  140.     //}}AFX_DISP_ID
  141.     };
  142. };
  143.