home *** CD-ROM | disk | FTP | other *** search
/ Team Palmtops 7 / Palmtops_numero07.iso / WinCE / SDKWindowsCE / HandHeldPCPro30 / sdk.exe / Jupiter SDK / data1.cab / MFC / include / afxdisp.h < prev    next >
Encoding:
C/C++ Source or Header  |  1999-02-19  |  49.9 KB  |  1,463 lines

  1. // This is a part of the Microsoft Foundation Classes C++ library.
  2. // Copyright (C) 1992-1998 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 related
  7. // electronic documentation provided with the library.
  8. // See these sources for detailed information regarding the
  9. // Microsoft Foundation Classes product.
  10.  
  11. #ifndef __AFXDISP_H__
  12. #define __AFXDISP_H__
  13.  
  14. #ifdef _AFX_NO_OLE_SUPPORT
  15.     #error OLE classes not supported in this library variant.
  16. #endif
  17.  
  18. #ifndef __AFXWIN_H__
  19.     #include <afxwin.h>
  20. #endif
  21.  
  22. // include necessary OLE headers
  23. #ifndef _OBJBASE_H_
  24.     #include <objbase.h>
  25. #endif
  26. #ifndef _OLEAUTO_H_
  27.     #include <oleauto.h>
  28. #endif
  29. #ifndef _OLECTL_H_
  30.     #include <olectl.h>
  31. #endif
  32. #ifndef __ocidl_h__
  33.     #include <ocidl.h>
  34. #endif
  35.  
  36. // Shell interface support
  37. #ifndef _SHLOBJ_H_
  38.     #include <shlobj.h>
  39. #endif
  40.  
  41. #ifdef _AFX_MINREBUILD
  42. #pragma component(minrebuild, off)
  43. #endif
  44. #ifndef _AFX_FULLTYPEINFO
  45. #pragma component(mintypeinfo, on)
  46. #endif
  47.  
  48. #ifndef _AFX_NOFORCE_LIBS
  49.  
  50. #if defined(_WIN32_WCE)
  51. /////////////////////////////////////////////////////////////////////////////
  52. // WinCE libraries
  53.  
  54. #ifdef _AFXDLL 
  55.     #if !defined(_AFX_CORE_IMPL) && !defined(_AFX_OLE_IMPL)
  56.         #if defined(_DEBUG)
  57.             #pragma comment(lib, WCE_OLE_FILENAME(D.LIB))
  58.         #else 
  59.             #pragma comment(lib, WCE_OLE_FILENAME(.LIB))
  60.         #endif 
  61.     #endif 
  62. #else 
  63.     #error "Can't build MFC OLE projects using static MFC libraries."
  64. #endif 
  65.  
  66. #pragma comment(lib, WCE_OLE32_LIB)
  67. #pragma comment(lib, WCE_OLEAUT32_LIB)
  68. #pragma comment(lib, "uuid.lib")
  69.  
  70. #else // _WIN32_WCE
  71. /////////////////////////////////////////////////////////////////////////////
  72. // Win32 libraries
  73.  
  74. #ifdef _AFXDLL
  75.     #if defined(_DEBUG) && !defined(_AFX_MONOLITHIC)
  76.         #ifndef _UNICODE
  77.             #pragma comment(lib, "mfco42d.lib")
  78.         #else
  79.             #pragma comment(lib, "mfco42ud.lib")
  80.         #endif
  81.     #endif
  82. #endif
  83.  
  84. #pragma comment(lib, "oledlg.lib")
  85. #pragma comment(lib, "ole32.lib")
  86. #pragma comment(lib, "olepro32.lib")
  87. #pragma comment(lib, "oleaut32.lib")
  88. #pragma comment(lib, "uuid.lib")
  89. #pragma comment(lib, "urlmon.lib")
  90.  
  91. #endif // _WIN32_WCE
  92. #endif //!_AFX_NOFORCE_LIBS
  93.  
  94. /////////////////////////////////////////////////////////////////////////////
  95.  
  96. #ifdef _AFX_PACKING
  97. #pragma pack(push, _AFX_PACKING)
  98. #endif
  99.  
  100. /////////////////////////////////////////////////////////////////////////////
  101. // AFXDISP - MFC IDispatch & ClassFactory support
  102.  
  103. // Classes declared in this file
  104.  
  105. //CException
  106.     class COleException;            // caught by client or server
  107.     class COleDispatchException;    // special exception for IDispatch calls
  108.  
  109. //CCmdTarget
  110.     class COleObjectFactory;        // glue for IClassFactory -> runtime class
  111.         class COleTemplateServer;   // server documents using CDocTemplate
  112.  
  113. class COleDispatchDriver;           // helper class to call IDispatch
  114.  
  115. class COleVariant;          // OLE VARIANT wrapper
  116. class COleCurrency;         // Based on OLE CY
  117. class COleDateTime;         // Based on OLE DATE
  118. class COleDateTimeSpan;     // Based on a double
  119. class COleSafeArray;        // Based on OLE VARIANT
  120. /////////////////////////////////////////////////////////////////////////////
  121.  
  122. // AFXDLL support
  123. #undef AFX_DATA
  124. #define AFX_DATA AFX_OLE_DATA
  125.  
  126. /////////////////////////////////////////////////////////////////////////////
  127. // OLE COM (Component Object Model) implementation infrastructure
  128. //      - data driven QueryInterface
  129. //      - standard implementation of aggregate AddRef and Release
  130. // (see CCmdTarget in AFXWIN.H for more information)
  131.  
  132. #define METHOD_PROLOGUE(theClass, localClass) \
  133.     theClass* pThis = \
  134.         ((theClass*)((BYTE*)this - offsetof(theClass, m_x##localClass))); \
  135.     AFX_MANAGE_STATE(pThis->m_pModuleState) \
  136.     pThis; // avoid warning from compiler \
  137.  
  138. #define METHOD_PROLOGUE_(theClass, localClass) \
  139.     theClass* pThis = \
  140.         ((theClass*)((BYTE*)this - offsetof(theClass, m_x##localClass))); \
  141.     pThis; // avoid warning from compiler \
  142.  
  143. #ifndef _AFX_NO_NESTED_DERIVATION
  144. #define METHOD_PROLOGUE_EX(theClass, localClass) \
  145.     theClass* pThis = ((theClass*)((BYTE*)this - m_nOffset)); \
  146.     AFX_MANAGE_STATE(pThis->m_pModuleState) \
  147.     pThis; // avoid warning from compiler \
  148.  
  149. #define METHOD_PROLOGUE_EX_(theClass, localClass) \
  150.     theClass* pThis = ((theClass*)((BYTE*)this - m_nOffset)); \
  151.     pThis; // avoid warning from compiler \
  152.  
  153. #else
  154. #define METHOD_PROLOGUE_EX(theClass, localClass) \
  155.     METHOD_PROLOGUE(theClass, localClass) \
  156.  
  157. #define METHOD_PROLOGUE_EX_(theClass, localClass) \
  158.     METHOD_PROLOGUE_(theClass, localClass) \
  159.  
  160. #endif
  161.  
  162. // Provided only for compatibility with CDK 1.x
  163. #define METHOD_MANAGE_STATE(theClass, localClass) \
  164.     METHOD_PROLOGUE_EX(theClass, localClass) \
  165.  
  166. #define BEGIN_INTERFACE_PART(localClass, baseClass) \
  167.     class X##localClass : public baseClass \
  168.     { \
  169.     public: \
  170.         STDMETHOD_(ULONG, AddRef)(); \
  171.         STDMETHOD_(ULONG, Release)(); \
  172.         STDMETHOD(QueryInterface)(REFIID iid, LPVOID* ppvObj); \
  173.  
  174. #ifndef _AFX_NO_NESTED_DERIVATION
  175. #define BEGIN_INTERFACE_PART_DERIVE(localClass, baseClass) \
  176.     class X##localClass : public baseClass \
  177.     { \
  178.     public: \
  179.  
  180. #else
  181. #define BEGIN_INTERFACE_PART_DERIVE(localClass, baseClass) \
  182.     BEGIN_INTERFACE_PART(localClass, baseClass) \
  183.  
  184. #endif
  185.  
  186. #ifndef _AFX_NO_NESTED_DERIVATION
  187. #define INIT_INTERFACE_PART(theClass, localClass) \
  188.         size_t m_nOffset; \
  189.         INIT_INTERFACE_PART_DERIVE(theClass, localClass) \
  190.  
  191. #define INIT_INTERFACE_PART_DERIVE(theClass, localClass) \
  192.         X##localClass() \
  193.             { m_nOffset = offsetof(theClass, m_x##localClass); } \
  194.  
  195. #else
  196. #define INIT_INTERFACE_PART(theClass, localClass)
  197. #define INIT_INTERFACE_PART_DERIVE(theClass, localClass)
  198.  
  199. #endif
  200.  
  201. // Note: Inserts the rest of OLE functionality between these two macros,
  202. //  depending upon the interface that is being implemented.  It is not
  203. //  necessary to include AddRef, Release, and QueryInterface since those
  204. //  member functions are declared by the macro.
  205.  
  206. #define END_INTERFACE_PART(localClass) \
  207.     } m_x##localClass; \
  208.     friend class X##localClass; \
  209.  
  210. struct CInterfacePlaceHolder
  211. {
  212.     DWORD m_vtbl;    // filled in with USE_INTERFACE_PART
  213.     CInterfacePlaceHolder() { m_vtbl = 0; }
  214. };
  215.  
  216. #define END_INTERFACE_PART_OPTIONAL(localClass) \
  217.     }; \
  218.     CInterfacePlaceHolder m_x##localClass; \
  219.     friend class X##localClass; \
  220.  
  221. #ifdef _AFXDLL
  222. #define END_INTERFACE_PART_STATIC END_INTERFACE_PART
  223. #else
  224. #define END_INTERFACE_PART_STATIC END_INTERFACE_PART
  225. #endif
  226.  
  227. #define USE_INTERFACE_PART(localClass) \
  228.     m_x##localClass.m_vtbl = *(DWORD*)&X##localClass(); \
  229.  
  230. #ifdef _AFXDLL
  231. #define BEGIN_INTERFACE_MAP(theClass, theBase) \
  232.     const AFX_INTERFACEMAP* PASCAL theClass::_GetBaseInterfaceMap() \
  233.         { return &theBase::interfaceMap; } \
  234.     const AFX_INTERFACEMAP* theClass::GetInterfaceMap() const \
  235.         { return &theClass::interfaceMap; } \
  236.     AFX_COMDAT const AFX_DATADEF AFX_INTERFACEMAP theClass::interfaceMap = \
  237.         { &theClass::_GetBaseInterfaceMap, &theClass::_interfaceEntries[0], }; \
  238.     AFX_COMDAT const AFX_DATADEF AFX_INTERFACEMAP_ENTRY theClass::_interfaceEntries[] = \
  239.     { \
  240.  
  241. #else
  242. #define BEGIN_INTERFACE_MAP(theClass, theBase) \
  243.     const AFX_INTERFACEMAP* theClass::GetInterfaceMap() const \
  244.         { return &theClass::interfaceMap; } \
  245.     AFX_COMDAT const AFX_DATADEF AFX_INTERFACEMAP theClass::interfaceMap = \
  246.         { &theBase::interfaceMap, &theClass::_interfaceEntries[0], }; \
  247.     AFX_COMDAT const AFX_DATADEF AFX_INTERFACEMAP_ENTRY theClass::_interfaceEntries[] = \
  248.     { \
  249.  
  250. #endif
  251.  
  252. #define INTERFACE_PART(theClass, iid, localClass) \
  253.         { &iid, offsetof(theClass, m_x##localClass) }, \
  254.  
  255. #define INTERFACE_AGGREGATE(theClass, theAggr) \
  256.         { NULL, offsetof(theClass, theAggr) }, \
  257.  
  258. #define END_INTERFACE_MAP() \
  259.         { NULL, (size_t)-1 } \
  260.     }; \
  261.  
  262. /////////////////////////////////////////////////////////////////////////////
  263. // COleException - unexpected or rare OLE error returned
  264.  
  265. class COleException : public CException
  266. {
  267.     DECLARE_DYNAMIC(COleException)
  268.  
  269. public:
  270.     SCODE m_sc;
  271.     static SCODE PASCAL Process(const CException* pAnyException);
  272.  
  273. // Implementation (use AfxThrowOleException to create)
  274. public:
  275.     COleException();
  276.     virtual ~COleException();
  277.  
  278.     virtual BOOL GetErrorMessage(LPTSTR lpszError, UINT nMaxError,
  279.         PUINT pnHelpContext = NULL);
  280. };
  281.  
  282. void AFXAPI AfxThrowOleException(SCODE sc);
  283. void AFXAPI AfxCheckError(SCODE sc);
  284.  
  285. /////////////////////////////////////////////////////////////////////////////
  286. // IDispatch specific exception
  287.  
  288. class COleDispatchException : public CException
  289. {
  290.     DECLARE_DYNAMIC(COleDispatchException)
  291.  
  292. public:
  293. // Attributes
  294.     WORD m_wCode;   // error code (specific to IDispatch implementation)
  295.     CString m_strDescription;   // human readable description of the error
  296.     DWORD m_dwHelpContext;      // help context for error
  297.  
  298.     // usually empty in application which creates it (eg. servers)
  299.     CString m_strHelpFile;      // help file to use with m_dwHelpContext
  300.     CString m_strSource;        // source of the error (name of server)
  301.  
  302. // Implementation
  303. public:
  304.     COleDispatchException(LPCTSTR lpszDescription, UINT nHelpID, WORD wCode);
  305.     virtual ~COleDispatchException();
  306.     static void PASCAL Process(
  307.         EXCEPINFO* pInfo, const CException* pAnyException);
  308.  
  309.     virtual BOOL GetErrorMessage(LPTSTR lpszError, UINT nMaxError,
  310.         PUINT pnHelpContext = NULL);
  311.  
  312.     SCODE m_scError;            // SCODE describing the error
  313. };
  314.  
  315. void AFXAPI AfxThrowOleDispatchException(WORD wCode, LPCTSTR lpszDescription,
  316.     UINT nHelpID = 0);
  317. void AFXAPI AfxThrowOleDispatchException(WORD wCode, UINT nDescriptionID,
  318.     UINT nHelpID = (UINT)-1);
  319.  
  320. /////////////////////////////////////////////////////////////////////////////
  321. // Macros for CCmdTarget IDispatchable classes
  322.  
  323. #ifdef _AFXDLL
  324. #define BEGIN_DISPATCH_MAP(theClass, baseClass) \
  325.     const AFX_DISPMAP* PASCAL theClass::_GetBaseDispatchMap() \
  326.         { return &baseClass::dispatchMap; } \
  327.     const AFX_DISPMAP* theClass::GetDispatchMap() const \
  328.         { return &theClass::dispatchMap; } \
  329.     AFX_COMDAT const AFX_DISPMAP theClass::dispatchMap = \
  330.         { &theClass::_GetBaseDispatchMap, &theClass::_dispatchEntries[0], \
  331.             &theClass::_dispatchEntryCount, &theClass::_dwStockPropMask }; \
  332.     AFX_COMDAT UINT theClass::_dispatchEntryCount = (UINT)-1; \
  333.     AFX_COMDAT DWORD theClass::_dwStockPropMask = (DWORD)-1; \
  334.     AFX_COMDAT const AFX_DISPMAP_ENTRY theClass::_dispatchEntries[] = \
  335.     { \
  336.  
  337. #else
  338. #define BEGIN_DISPATCH_MAP(theClass, baseClass) \
  339.     const AFX_DISPMAP* theClass::GetDispatchMap() const \
  340.         { return &theClass::dispatchMap; } \
  341.     AFX_COMDAT const AFX_DISPMAP theClass::dispatchMap = \
  342.         { &baseClass::dispatchMap, &theClass::_dispatchEntries[0], \
  343.             &theClass::_dispatchEntryCount, &theClass::_dwStockPropMask }; \
  344.     AFX_COMDAT UINT theClass::_dispatchEntryCount = (UINT)-1; \
  345.     AFX_COMDAT DWORD theClass::_dwStockPropMask = (DWORD)-1; \
  346.     AFX_COMDAT const AFX_DISPMAP_ENTRY theClass::_dispatchEntries[] = \
  347.     { \
  348.  
  349. #endif
  350.  
  351. #define END_DISPATCH_MAP() \
  352.     { VTS_NONE, DISPID_UNKNOWN, VTS_NONE, VT_VOID, \
  353.         (AFX_PMSG)NULL, (AFX_PMSG)NULL, (size_t)-1, afxDispCustom } }; \
  354.  
  355. // parameter types: by value VTs
  356. #define VTS_I2              "\x02"      // a 'short'
  357. #define VTS_I4              "\x03"      // a 'long'
  358. #define VTS_R4              "\x04"      // a 'float'
  359. #define VTS_R8              "\x05"      // a 'double'
  360. #define VTS_CY              "\x06"      // a 'CY' or 'CY*'
  361. #define VTS_DATE            "\x07"      // a 'DATE'
  362. #define VTS_WBSTR           "\x08"      // an 'LPCOLESTR'
  363. #define VTS_DISPATCH        "\x09"      // an 'IDispatch*'
  364. #define VTS_SCODE           "\x0A"      // an 'SCODE'
  365. #define VTS_BOOL            "\x0B"      // a 'BOOL'
  366. #define VTS_VARIANT         "\x0C"      // a 'const VARIANT&' or 'VARIANT*'
  367. #define VTS_UNKNOWN         "\x0D"      // an 'IUnknown*'
  368. #if defined(_UNICODE) || defined(OLE2ANSI)
  369.     #define VTS_BSTR            VTS_WBSTR// an 'LPCOLESTR'
  370.     #define VT_BSTRT            VT_BSTR
  371. #else
  372.     #define VTS_BSTR            "\x0E"  // an 'LPCSTR'
  373.     #define VT_BSTRA            14
  374.     #define VT_BSTRT            VT_BSTRA
  375. #endif
  376. #define VTS_UI1             "\x0F"      // a 'BYTE'
  377.  
  378. // parameter types: by reference VTs
  379. #define VTS_PI2             "\x42"      // a 'short*'
  380. #define VTS_PI4             "\x43"      // a 'long*'
  381. #define VTS_PR4             "\x44"      // a 'float*'
  382. #define VTS_PR8             "\x45"      // a 'double*'
  383. #define VTS_PCY             "\x46"      // a 'CY*'
  384. #define VTS_PDATE           "\x47"      // a 'DATE*'
  385. #define VTS_PBSTR           "\x48"      // a 'BSTR*'
  386. #define VTS_PDISPATCH       "\x49"      // an 'IDispatch**'
  387. #define VTS_PSCODE          "\x4A"      // an 'SCODE*'
  388. #define VTS_PBOOL           "\x4B"      // a 'VARIANT_BOOL*'
  389. #define VTS_PVARIANT        "\x4C"      // a 'VARIANT*'
  390. #define VTS_PUNKNOWN        "\x4D"      // an 'IUnknown**'
  391. #define VTS_PUI1            "\x4F"      // a 'BYTE*'
  392.  
  393. // special VT_ and VTS_ values
  394. #define VTS_NONE            NULL        // used for members with 0 params
  395. #define VT_MFCVALUE         0xFFF       // special value for DISPID_VALUE
  396. #define VT_MFCBYREF         0x40        // indicates VT_BYREF type
  397. #define VT_MFCMARKER        0xFF        // delimits named parameters (INTERNAL USE)
  398.  
  399. // variant handling (use V_BSTRT when you have ANSI BSTRs, as in DAO)
  400. #ifndef _UNICODE
  401.     #define V_BSTRT(b)  (LPSTR)V_BSTR(b)
  402. #else
  403.     #define V_BSTRT(b)  V_BSTR(b)
  404. #endif
  405.  
  406. /////////////////////////////////////////////////////////////////////////////
  407. // OLE control parameter types
  408.  
  409. #define VTS_COLOR           VTS_I4      // OLE_COLOR
  410. #define VTS_XPOS_PIXELS     VTS_I4      // OLE_XPOS_PIXELS
  411. #define VTS_YPOS_PIXELS     VTS_I4      // OLE_YPOS_PIXELS
  412. #define VTS_XSIZE_PIXELS    VTS_I4      // OLE_XSIZE_PIXELS
  413. #define VTS_YSIZE_PIXELS    VTS_I4      // OLE_YSIZE_PIXELS
  414. #define VTS_XPOS_HIMETRIC   VTS_I4      // OLE_XPOS_HIMETRIC
  415. #define VTS_YPOS_HIMETRIC   VTS_I4      // OLE_YPOS_HIMETRIC
  416. #define VTS_XSIZE_HIMETRIC  VTS_I4      // OLE_XSIZE_HIMETRIC
  417. #define VTS_YSIZE_HIMETRIC  VTS_I4      // OLE_YSIZE_HIMETRIC
  418. #define VTS_TRISTATE        VTS_I2      // OLE_TRISTATE
  419. #define VTS_OPTEXCLUSIVE    VTS_BOOL    // OLE_OPTEXCLUSIVE
  420.  
  421. #define VTS_PCOLOR          VTS_PI4     // OLE_COLOR*
  422. #define VTS_PXPOS_PIXELS    VTS_PI4     // OLE_XPOS_PIXELS*
  423. #define VTS_PYPOS_PIXELS    VTS_PI4     // OLE_YPOS_PIXELS*
  424. #define VTS_PXSIZE_PIXELS   VTS_PI4     // OLE_XSIZE_PIXELS*
  425. #define VTS_PYSIZE_PIXELS   VTS_PI4     // OLE_YSIZE_PIXELS*
  426. #define VTS_PXPOS_HIMETRIC  VTS_PI4     // OLE_XPOS_HIMETRIC*
  427. #define VTS_PYPOS_HIMETRIC  VTS_PI4     // OLE_YPOS_HIMETRIC*
  428. #define VTS_PXSIZE_HIMETRIC VTS_PI4     // OLE_XSIZE_HIMETRIC*
  429. #define VTS_PYSIZE_HIMETRIC VTS_PI4     // OLE_YSIZE_HIMETRIC*
  430. #define VTS_PTRISTATE       VTS_PI2     // OLE_TRISTATE*
  431. #define VTS_POPTEXCLUSIVE   VTS_PBOOL   // OLE_OPTEXCLUSIVE*
  432.  
  433. #define VTS_FONT            VTS_DISPATCH    // IFontDispatch*
  434. #define VTS_PICTURE         VTS_DISPATCH    // IPictureDispatch*
  435.  
  436. #define VTS_HANDLE          VTS_I4      // OLE_HANDLE
  437. #define VTS_PHANDLE         VTS_PI4     // OLE_HANDLE*
  438.  
  439. // these DISP_ macros cause the framework to generate the DISPID
  440. #define DISP_FUNCTION(theClass, szExternalName, pfnMember, vtRetVal, vtsParams) \
  441.     { _T(szExternalName), DISPID_UNKNOWN, vtsParams, vtRetVal, \
  442.         (AFX_PMSG)(void (theClass::*)(void))&pfnMember, (AFX_PMSG)0, 0, \
  443.         afxDispCustom }, \
  444.  
  445. #define DISP_PROPERTY(theClass, szExternalName, memberName, vtPropType) \
  446.     { _T(szExternalName), DISPID_UNKNOWN, NULL, vtPropType, (AFX_PMSG)0, (AFX_PMSG)0, \
  447.         offsetof(theClass, memberName), afxDispCustom }, \
  448.  
  449. #define DISP_PROPERTY_NOTIFY(theClass, szExternalName, memberName, pfnAfterSet, vtPropType) \
  450.     { _T(szExternalName), DISPID_UNKNOWN, NULL, vtPropType, (AFX_PMSG)0, \
  451.         (AFX_PMSG)(void (theClass::*)(void))&pfnAfterSet, \
  452.         offsetof(theClass, memberName), afxDispCustom }, \
  453.  
  454. #define DISP_PROPERTY_EX(theClass, szExternalName, pfnGet, pfnSet, vtPropType) \
  455.     { _T(szExternalName), DISPID_UNKNOWN, NULL, vtPropType, \
  456.         (AFX_PMSG)(void (theClass::*)(void))&pfnGet, \
  457.         (AFX_PMSG)(void (theClass::*)(void))&pfnSet, 0, afxDispCustom }, \
  458.  
  459. #define DISP_PROPERTY_PARAM(theClass, szExternalName, pfnGet, pfnSet, vtPropType, vtsParams) \
  460.     { _T(szExternalName), DISPID_UNKNOWN, vtsParams, vtPropType, \
  461.         (AFX_PMSG)(void (theClass::*)(void))&pfnGet, \
  462.         (AFX_PMSG)(void (theClass::*)(void))&pfnSet, 0, afxDispCustom }, \
  463.  
  464. // these DISP_ macros allow the app to determine the DISPID
  465. #define DISP_FUNCTION_ID(theClass, szExternalName, dispid, pfnMember, vtRetVal, vtsParams) \
  466.     { _T(szExternalName), dispid, vtsParams, vtRetVal, \
  467.         (AFX_PMSG)(void (theClass::*)(void))&pfnMember, (AFX_PMSG)0, 0, \
  468.         afxDispCustom }, \
  469.  
  470. #define DISP_PROPERTY_ID(theClass, szExternalName, dispid, memberName, vtPropType) \
  471.     { _T(szExternalName), dispid, NULL, vtPropType, (AFX_PMSG)0, (AFX_PMSG)0, \
  472.         offsetof(theClass, memberName), afxDispCustom }, \
  473.  
  474. #define DISP_PROPERTY_NOTIFY_ID(theClass, szExternalName, dispid, memberName, pfnAfterSet, vtPropType) \
  475.     { _T(szExternalName), dispid, NULL, vtPropType, (AFX_PMSG)0, \
  476.         (AFX_PMSG)(void (theClass::*)(void))&pfnAfterSet, \
  477.         offsetof(theClass, memberName), afxDispCustom }, \
  478.  
  479. #define DISP_PROPERTY_EX_ID(theClass, szExternalName, dispid, pfnGet, pfnSet, vtPropType) \
  480.     { _T(szExternalName), dispid, NULL, vtPropType, \
  481.         (AFX_PMSG)(void (theClass::*)(void))&pfnGet, \
  482.         (AFX_PMSG)(void (theClass::*)(void))&pfnSet, 0, afxDispCustom }, \
  483.  
  484. #define DISP_PROPERTY_PARAM_ID(theClass, szExternalName, dispid, pfnGet, pfnSet, vtPropType, vtsParams) \
  485.     { _T(szExternalName), dispid, vtsParams, vtPropType, \
  486.         (AFX_PMSG)(void (theClass::*)(void))&pfnGet, \
  487.         (AFX_PMSG)(void (theClass::*)(void))&pfnSet, 0, afxDispCustom }, \
  488.  
  489. // the DISP_DEFVALUE is a special case macro that creates an alias for DISPID_VALUE
  490. #define DISP_DEFVALUE(theClass, szExternalName) \
  491.     { _T(szExternalName), DISPID_UNKNOWN, NULL, VT_MFCVALUE, \
  492.         (AFX_PMSG)0, (AFX_PMSG)0, 0, afxDispCustom }, \
  493.  
  494. #define DISP_DEFVALUE_ID(theClass, dispid) \
  495.     { NULL, dispid, NULL, VT_MFCVALUE, (AFX_PMSG)0, (AFX_PMSG)0, 0, \
  496.         afxDispCustom }, \
  497.  
  498. /////////////////////////////////////////////////////////////////////////////
  499. // Macros for creating "creatable" automation classes.
  500.  
  501. #define DECLARE_OLECREATE(class_name) \
  502. public: \
  503.     static AFX_DATA COleObjectFactory factory; \
  504.     static AFX_DATA const GUID guid; \
  505.  
  506. #define IMPLEMENT_OLECREATE(class_name, external_name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
  507.     AFX_DATADEF COleObjectFactory class_name::factory(class_name::guid, \
  508.         RUNTIME_CLASS(class_name), FALSE, _T(external_name)); \
  509.     AFX_COMDAT const AFX_DATADEF GUID class_name::guid = \
  510.         { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } }; \
  511.  
  512. /////////////////////////////////////////////////////////////////////////////
  513. // Helper class for driving IDispatch
  514.  
  515. class COleDispatchDriver
  516. {
  517. // Constructors
  518. public:
  519.     COleDispatchDriver();
  520.     COleDispatchDriver(LPDISPATCH lpDispatch, BOOL bAutoRelease = TRUE);
  521.     COleDispatchDriver(const COleDispatchDriver& dispatchSrc);
  522.  
  523. // Attributes
  524.     LPDISPATCH m_lpDispatch;
  525.     BOOL m_bAutoRelease;
  526.  
  527. // Operations
  528.     BOOL CreateDispatch(REFCLSID clsid, COleException* pError = NULL);
  529.     BOOL CreateDispatch(LPCTSTR lpszProgID, COleException* pError = NULL);
  530.  
  531.     void AttachDispatch(LPDISPATCH lpDispatch, BOOL bAutoRelease = TRUE);
  532.     LPDISPATCH DetachDispatch();
  533.         // detach and get ownership of m_lpDispatch
  534.     void ReleaseDispatch();
  535.  
  536.     // helpers for IDispatch::Invoke
  537.     void AFX_CDECL InvokeHelper(DISPID dwDispID, WORD wFlags,
  538.         VARTYPE vtRet, void* pvRet, const BYTE* pbParamInfo, ...);
  539.     void AFX_CDECL SetProperty(DISPID dwDispID, VARTYPE vtProp, ...);
  540.     void GetProperty(DISPID dwDispID, VARTYPE vtProp, void* pvProp) const;
  541.  
  542.     // special operators
  543.     operator LPDISPATCH();
  544.     const COleDispatchDriver& operator=(const COleDispatchDriver& dispatchSrc);
  545.  
  546. // Implementation
  547. public:
  548.     ~COleDispatchDriver();
  549.     void InvokeHelperV(DISPID dwDispID, WORD wFlags, VARTYPE vtRet,
  550.         void* pvRet, const BYTE* pbParamInfo, va_list argList);
  551. };
  552.  
  553. /////////////////////////////////////////////////////////////////////////////
  554. // Class Factory implementation (binds OLE class factory -> runtime class)
  555. //  (all specific class factories derive from this class factory)
  556.  
  557. #if defined(_WIN32_WCE)
  558. // WinCE: fixes a compiler error related to the friend keyword below
  559. STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv);
  560. #endif // _WIN32_WCE
  561. class COleObjectFactory : public CCmdTarget
  562. {
  563.     DECLARE_DYNAMIC(COleObjectFactory)
  564.  
  565. // Construction
  566. public:
  567.     COleObjectFactory(REFCLSID clsid, CRuntimeClass* pRuntimeClass,
  568.         BOOL bMultiInstance, LPCTSTR lpszProgID);
  569.  
  570. // Attributes
  571.     virtual BOOL IsRegistered() const;
  572.     REFCLSID GetClassID() const;
  573.  
  574. // Operations
  575.     virtual BOOL Register();
  576.     BOOL Unregister();
  577. WCE_DEL    void Revoke();
  578.     void UpdateRegistry(LPCTSTR lpszProgID = NULL);
  579.         // default uses m_lpszProgID if not NULL
  580.     BOOL IsLicenseValid();
  581.  
  582.     static BOOL PASCAL UnregisterAll();
  583.     static BOOL PASCAL RegisterAll();
  584. WCE_DEL    static void PASCAL RevokeAll();
  585.     static BOOL PASCAL UpdateRegistryAll(BOOL bRegister = TRUE);
  586.  
  587. // Overridables
  588. protected:
  589.     virtual CCmdTarget* OnCreateObject();
  590.     virtual BOOL UpdateRegistry(BOOL bRegister);
  591.     virtual BOOL VerifyUserLicense();
  592.     virtual BOOL GetLicenseKey(DWORD dwReserved, BSTR* pbstrKey);
  593.     virtual BOOL VerifyLicenseKey(BSTR bstrKey);
  594.  
  595. // Implementation
  596. public:
  597.     virtual ~COleObjectFactory();
  598. #ifdef _DEBUG
  599.     void AssertValid() const;
  600.     void Dump(CDumpContext& dc) const;
  601. #endif
  602.  
  603. public:
  604.     COleObjectFactory* m_pNextFactory;  // list of factories maintained
  605.  
  606. protected:
  607.     DWORD m_dwRegister;             // registry identifier
  608.     CLSID m_clsid;                  // registered class ID
  609.     CRuntimeClass* m_pRuntimeClass; // runtime class of CCmdTarget derivative
  610.     BOOL m_bMultiInstance;          // multiple instance?
  611.     LPCTSTR m_lpszProgID;           // human readable class ID
  612.     BYTE m_bLicenseChecked;
  613.     BYTE m_bLicenseValid;
  614.     BYTE m_bRegistered;             // is currently registered w/ system
  615.     BYTE m_bOAT;                          // used by COleTemplateServer to
  616.                                               // remember application type for unregistry
  617.  
  618. // Interface Maps
  619. public:
  620.     BEGIN_INTERFACE_PART(ClassFactory, IClassFactory2)
  621.         INIT_INTERFACE_PART(COleObjectFactory, ClassFactory)
  622.         STDMETHOD(CreateInstance)(LPUNKNOWN, REFIID, LPVOID*);
  623.         STDMETHOD(LockServer)(BOOL);
  624.         STDMETHOD(GetLicInfo)(LPLICINFO);
  625.         STDMETHOD(RequestLicKey)(DWORD, BSTR*);
  626.         STDMETHOD(CreateInstanceLic)(LPUNKNOWN, LPUNKNOWN, REFIID, BSTR,
  627.             LPVOID*);
  628.     END_INTERFACE_PART(ClassFactory)
  629.  
  630.     DECLARE_INTERFACE_MAP()
  631.  
  632.     friend SCODE AFXAPI AfxDllGetClassObject(REFCLSID, REFIID, LPVOID*);
  633.     friend SCODE STDAPICALLTYPE DllGetClassObject(REFCLSID, REFIID, LPVOID*);
  634. };
  635.  
  636. // Define COleObjectFactoryEx for compatibility with old CDK
  637. #define COleObjectFactoryEx COleObjectFactory
  638.  
  639. //////////////////////////////////////////////////////////////////////////////
  640. // COleTemplateServer - COleObjectFactory using CDocTemplates
  641.  
  642. // This enumeration is used in AfxOleRegisterServerClass to pick the
  643. //  correct registration entries given the application type.
  644. enum OLE_APPTYPE
  645. {
  646.     OAT_UNKNOWN = -1,                // no type decided yet
  647.     OAT_INPLACE_SERVER = 0,     // server has full server user-interface
  648.     OAT_SERVER = 1,             // server supports only embedding
  649.     OAT_CONTAINER = 2,          // container supports links to embeddings
  650.     OAT_DISPATCH_OBJECT = 3,    // IDispatch capable object
  651.     OAT_DOC_OBJECT_SERVER = 4,  // sever supports DocObject embedding
  652.     OAT_DOC_OBJECT_CONTAINER =5,// container supports DocObject clients
  653. };
  654.  
  655. #if !defined(_WIN32_WCE)
  656. class COleTemplateServer : public COleObjectFactory
  657. {
  658. // Constructors
  659. public:
  660.     COleTemplateServer();
  661.  
  662. // Operations
  663.     void ConnectTemplate(REFCLSID clsid, CDocTemplate* pDocTemplate,
  664.         BOOL bMultiInstance);
  665.         // set doc template after creating it in InitInstance
  666.     void UpdateRegistry(OLE_APPTYPE nAppType = OAT_INPLACE_SERVER,
  667.         LPCTSTR* rglpszRegister = NULL, LPCTSTR* rglpszOverwrite = NULL);
  668.         // may want to UpdateRegistry if not run with /Embedded
  669.     BOOL Register();
  670.     BOOL Unregister();
  671.  
  672. // Implementation
  673. protected:
  674.     virtual BOOL OnCmdMsg(UINT nID, int nCode, void* pExtra,
  675.             AFX_CMDHANDLERINFO* pHandlerInfo);
  676.     virtual CCmdTarget* OnCreateObject();
  677.     CDocTemplate* m_pDocTemplate;
  678.  
  679. private:
  680.     void UpdateRegistry(LPCTSTR lpszProgID);
  681.         // hide base class version of UpdateRegistry
  682. };
  683. #endif // _WIN32_WCE
  684.  
  685. /////////////////////////////////////////////////////////////////////////////
  686. // System registry helpers
  687.  
  688. // Helper to register server in case of no .REG file loaded
  689. BOOL AFXAPI AfxOleRegisterServerClass(
  690.     REFCLSID clsid, LPCTSTR lpszClassName,
  691.     LPCTSTR lpszShortTypeName, LPCTSTR lpszLongTypeName,
  692.     OLE_APPTYPE nAppType = OAT_SERVER,
  693.     LPCTSTR* rglpszRegister = NULL, LPCTSTR* rglpszOverwrite = NULL,
  694.     int nIconIndex = 0, LPCTSTR lpszLocalFilterName = NULL);
  695. BOOL AFXAPI AfxOleRegisterServerClass(
  696.     REFCLSID clsid, LPCTSTR lpszClassName,
  697.     LPCTSTR lpszShortTypeName, LPCTSTR lpszLongTypeName,
  698.     OLE_APPTYPE nAppType,
  699.     LPCTSTR* rglpszRegister, LPCTSTR* rglpszOverwrite,
  700.     int nIconIndex, LPCTSTR lpszLocalFilterName, LPCTSTR lpszLocalFilterExt);
  701.  
  702. BOOL AFXAPI AfxOleUnregisterServerClass(
  703.     REFCLSID clsid, LPCTSTR lpszClassName, LPCTSTR lpszShortTypeName,
  704.     LPCTSTR lpszLongTypeName, OLE_APPTYPE nAppType = OAT_SERVER,
  705.     LPCTSTR* rglpszRegister = NULL, LPCTSTR* rglpszOverwrite = NULL);
  706.  
  707. // AfxOleRegisterHelper is a worker function used by
  708. //  AfxOleRegisterServerClass (available for advanced registry work)
  709. BOOL AFXAPI AfxOleRegisterHelper(LPCTSTR const* rglpszRegister,
  710.     LPCTSTR const* rglpszSymbols, int nSymbols, BOOL bReplace,
  711.     HKEY hKeyRoot = ((HKEY)0x80000000)); // HKEY_CLASSES_ROOT
  712.  
  713. BOOL AFXAPI AfxOleUnregisterHelper(LPCTSTR const* rglpszRegister,
  714.     LPCTSTR const* rglpszSymbols, int nSymbols,
  715.     HKEY hKeyRoot = ((HKEY)0x80000000)); // HKEY_CLASSES_ROOT
  716.  
  717. /////////////////////////////////////////////////////////////////////////////
  718. // Connection maps
  719.  
  720. #define BEGIN_CONNECTION_PART(theClass, localClass) \
  721.     class X##localClass : public CConnectionPoint \
  722.     { \
  723.     public: \
  724.         X##localClass() \
  725.             { m_nOffset = offsetof(theClass, m_x##localClass); }
  726.  
  727. #define CONNECTION_IID(iid) \
  728.         REFIID GetIID() { return iid; }
  729.  
  730. #define END_CONNECTION_PART(localClass) \
  731.     } m_x##localClass; \
  732.     friend class X##localClass;
  733.  
  734. #ifdef _AFXDLL
  735. #define BEGIN_CONNECTION_MAP(theClass, theBase) \
  736.     const AFX_CONNECTIONMAP* PASCAL theClass::_GetBaseConnectionMap() \
  737.         { return &theBase::connectionMap; } \
  738.     const AFX_CONNECTIONMAP* theClass::GetConnectionMap() const \
  739.         { return &theClass::connectionMap; } \
  740.     AFX_COMDAT const AFX_DATADEF AFX_CONNECTIONMAP theClass::connectionMap = \
  741.         { &theClass::_GetBaseConnectionMap, &theClass::_connectionEntries[0], }; \
  742.     AFX_COMDAT const AFX_DATADEF AFX_CONNECTIONMAP_ENTRY theClass::_connectionEntries[] = \
  743.     { \
  744.  
  745. #else
  746. #define BEGIN_CONNECTION_MAP(theClass, theBase) \
  747.     const AFX_CONNECTIONMAP* theClass::GetConnectionMap() const \
  748.         { return &theClass::connectionMap; } \
  749.     AFX_COMDAT const AFX_DATADEF AFX_CONNECTIONMAP theClass::connectionMap = \
  750.         { &(theBase::connectionMap), &theClass::_connectionEntries[0], }; \
  751.     AFX_COMDAT const AFX_DATADEF AFX_CONNECTIONMAP_ENTRY theClass::_connectionEntries[] = \
  752.     { \
  753.  
  754. #endif
  755.  
  756. #define CONNECTION_PART(theClass, iid, localClass) \
  757.         { &iid, offsetof(theClass, m_x##localClass) }, \
  758.  
  759. #define END_CONNECTION_MAP() \
  760.         { NULL, (size_t)-1 } \
  761.     }; \
  762.  
  763. /////////////////////////////////////////////////////////////////////////////
  764. // CConnectionPoint
  765.  
  766. #ifdef _AFXDLL
  767. class CConnectionPoint : public CCmdTarget
  768. #else
  769. class AFX_NOVTABLE CConnectionPoint : public CCmdTarget
  770. #endif
  771. {
  772. // Constructors
  773. public:
  774.     CConnectionPoint();
  775.  
  776. // Operations
  777.     POSITION GetStartPosition() const;
  778.     LPUNKNOWN GetNextConnection(POSITION& pos) const;
  779.     const CPtrArray* GetConnections();  // obsolete
  780.  
  781. // Overridables
  782.     virtual LPCONNECTIONPOINTCONTAINER GetContainer();
  783.     virtual REFIID GetIID() = 0;
  784.     virtual void OnAdvise(BOOL bAdvise);
  785.     virtual int GetMaxConnections();
  786.     virtual LPUNKNOWN QuerySinkInterface(LPUNKNOWN pUnkSink);
  787.  
  788. // Implementation
  789.     ~CConnectionPoint();
  790.     void CreateConnectionArray();
  791.     int GetConnectionCount();
  792.  
  793. protected:
  794.     size_t m_nOffset;
  795.     LPUNKNOWN m_pUnkFirstConnection;
  796.     CPtrArray* m_pConnections;
  797.  
  798. // Interface Maps
  799. public:
  800.     BEGIN_INTERFACE_PART(ConnPt, IConnectionPoint)
  801.         INIT_INTERFACE_PART(CConnectionPoint, ConnPt)
  802.         STDMETHOD(GetConnectionInterface)(IID* pIID);
  803.         STDMETHOD(GetConnectionPointContainer)(
  804.             IConnectionPointContainer** ppCPC);
  805.         STDMETHOD(Advise)(LPUNKNOWN pUnkSink, DWORD* pdwCookie);
  806.         STDMETHOD(Unadvise)(DWORD dwCookie);
  807.         STDMETHOD(EnumConnections)(LPENUMCONNECTIONS* ppEnum);
  808.     END_INTERFACE_PART(ConnPt)
  809. };
  810.  
  811. /////////////////////////////////////////////////////////////////////////////
  812. // EventSink Maps
  813.  
  814. #ifndef _AFX_NO_OCC_SUPPORT
  815.  
  816. #ifdef _AFXDLL
  817. #define BEGIN_EVENTSINK_MAP(theClass, baseClass) \
  818.     const AFX_EVENTSINKMAP* PASCAL theClass::_GetBaseEventSinkMap() \
  819.         { return &baseClass::eventsinkMap; } \
  820.     const AFX_EVENTSINKMAP* theClass::GetEventSinkMap() const \
  821.         { return &theClass::eventsinkMap; } \
  822.     const AFX_EVENTSINKMAP theClass::eventsinkMap = \
  823.         { &theClass::_GetBaseEventSinkMap, &theClass::_eventsinkEntries[0], \
  824.             &theClass::_eventsinkEntryCount }; \
  825.     UINT theClass::_eventsinkEntryCount = (UINT)-1; \
  826.     const AFX_EVENTSINKMAP_ENTRY theClass::_eventsinkEntries[] = \
  827.     { \
  828.  
  829. #else
  830. #define BEGIN_EVENTSINK_MAP(theClass, baseClass) \
  831.     const AFX_EVENTSINKMAP* theClass::GetEventSinkMap() const \
  832.         { return &theClass::eventsinkMap; } \
  833.     const AFX_EVENTSINKMAP theClass::eventsinkMap = \
  834.         { &baseClass::eventsinkMap, &theClass::_eventsinkEntries[0], \
  835.             &theClass::_eventsinkEntryCount }; \
  836.     UINT theClass::_eventsinkEntryCount = (UINT)-1; \
  837.     const AFX_EVENTSINKMAP_ENTRY theClass::_eventsinkEntries[] = \
  838.     { \
  839.  
  840. #endif
  841.  
  842. #define END_EVENTSINK_MAP() \
  843.     { VTS_NONE, DISPID_UNKNOWN, VTS_NONE, VT_VOID, \
  844.         (AFX_PMSG)NULL, (AFX_PMSG)NULL, (size_t)-1, afxDispCustom, \
  845.         (UINT)-1, 0 } }; \
  846.  
  847. #define ON_EVENT(theClass, id, dispid, pfnHandler, vtsParams) \
  848.     { _T(""), dispid, vtsParams, VT_BOOL, \
  849.         (AFX_PMSG)(void (theClass::*)(void))&pfnHandler, (AFX_PMSG)0, 0, \
  850.         afxDispCustom, id, (UINT)-1 }, \
  851.  
  852. #define ON_EVENT_RANGE(theClass, idFirst, idLast, dispid, pfnHandler, vtsParams) \
  853.     { _T(""), dispid, vtsParams, VT_BOOL, \
  854.         (AFX_PMSG)(void (theClass::*)(void))&pfnHandler, (AFX_PMSG)0, 0, \
  855.         afxDispCustom, idFirst, idLast }, \
  856.  
  857. #define ON_PROPNOTIFY(theClass, id, dispid, pfnRequest, pfnChanged) \
  858.     { _T(""), dispid, VTS_NONE, VT_VOID, \
  859.         (AFX_PMSG)(BOOL (CCmdTarget::*)(BOOL*))&pfnRequest, \
  860.         (AFX_PMSG)(BOOL (CCmdTarget::*)(void))&pfnChanged, \
  861.         1, afxDispCustom, id, (UINT)-1 }, \
  862.  
  863. #define ON_PROPNOTIFY_RANGE(theClass, idFirst, idLast, dispid, pfnRequest, pfnChanged) \
  864.     { _T(""), dispid, VTS_NONE, VT_VOID, \
  865.         (AFX_PMSG)(BOOL (CCmdTarget::*)(UINT, BOOL*))&pfnRequest, \
  866.         (AFX_PMSG)(BOOL (CCmdTarget::*)(UINT))&pfnChanged, \
  867.         1, afxDispCustom, idFirst, idLast }, \
  868.  
  869. #define ON_DSCNOTIFY(theClass, id, pfnNotify) \
  870.     { _T(""), DISPID_UNKNOWN, VTS_NONE, VT_VOID, \
  871.         (AFX_PMSG)(BOOL (CCmdTarget::*)(DSCSTATE, DSCREASON, BOOL*))&pfnNotify, (AFX_PMSG)0, \
  872.         1, afxDispCustom, id, (UINT)-1 }, \
  873.  
  874. #define ON_DSCNOTIFY_RANGE(theClass, idFirst, idLast, pfnNotify) \
  875.     { _T(""), DISPID_UNKNOWN, VTS_NONE, VT_VOID, \
  876.         (AFX_PMSG)(BOOL (CCmdTarget::*)(UINT, DSCSTATE, DSCREASON, BOOL*))&pfnNotify, (AFX_PMSG)0, \
  877.         1, afxDispCustom, idFirst, idLast }, \
  878.  
  879. #define ON_EVENT_REFLECT(theClass, dispid, pfnHandler, vtsParams) \
  880.     { _T(""), dispid, vtsParams, VT_BOOL, \
  881.         (AFX_PMSG)(void (theClass::*)(void))&pfnHandler, (AFX_PMSG)0, 0, \
  882.         afxDispCustom, (UINT)-1, (UINT)-1 }, \
  883.  
  884. #define ON_PROPNOTIFY_REFLECT(theClass, dispid, pfnRequest, pfnChanged) \
  885.     { _T(""), dispid, VTS_NONE, VT_VOID, \
  886.         (AFX_PMSG)(BOOL (CCmdTarget::*)(BOOL*))&pfnRequest, \
  887.         (AFX_PMSG)(BOOL (CCmdTarget::*)(void))&pfnChanged, \
  888.         1, afxDispCustom, (UINT)-1, (UINT)-1 }, \
  889.  
  890. #endif // !_AFX_NO_OCC_SUPPORT
  891.  
  892. /////////////////////////////////////////////////////////////////////////////
  893. // Macros for type library information
  894.  
  895. CTypeLibCache* AFXAPI AfxGetTypeLibCache(const GUID* pTypeLibID);
  896.  
  897. #define DECLARE_OLETYPELIB(class_name) \
  898.     protected: \
  899.         virtual UINT GetTypeInfoCount(); \
  900.         virtual HRESULT GetTypeLib(LCID, LPTYPELIB*); \
  901.         virtual CTypeLibCache* GetTypeLibCache(); \
  902.  
  903. #define IMPLEMENT_OLETYPELIB(class_name, tlid, wVerMajor, wVerMinor) \
  904.     UINT class_name::GetTypeInfoCount() \
  905.         { return 1; } \
  906.     HRESULT class_name::GetTypeLib(LCID lcid, LPTYPELIB* ppTypeLib) \
  907.         { return ::LoadRegTypeLib(tlid, wVerMajor, wVerMinor, lcid, ppTypeLib); } \
  908.     CTypeLibCache* class_name::GetTypeLibCache() \
  909.         { AFX_MANAGE_STATE(m_pModuleState); return AfxGetTypeLibCache(&tlid); } \
  910.  
  911. /////////////////////////////////////////////////////////////////////////////
  912. // Init & Term helpers
  913.  
  914. BOOL AFXAPI AfxOleInit();
  915. void AFXAPI AfxOleTerm(BOOL bJustRevoke = FALSE);
  916. void AFXAPI AfxOleTermOrFreeLib(BOOL bTerm = TRUE, BOOL bJustRevoke = FALSE);
  917.  
  918. /////////////////////////////////////////////////////////////////////////////
  919. // Memory management helpers (for OLE task allocator memory)
  920.  
  921. #define AfxAllocTaskMem(nSize) CoTaskMemAlloc(nSize)
  922. #define AfxFreeTaskMem(p) CoTaskMemFree(p)
  923.  
  924. LPWSTR AFXAPI AfxAllocTaskWideString(LPCWSTR lpszString);
  925. LPWSTR AFXAPI AfxAllocTaskWideString(LPCSTR lpszString);
  926. LPSTR AFXAPI AfxAllocTaskAnsiString(LPCWSTR lpszString);
  927. LPSTR AFXAPI AfxAllocTaskAnsiString(LPCSTR lpszString);
  928.  
  929. #ifdef _UNICODE
  930.     #define AfxAllocTaskString(x) AfxAllocTaskWideString(x)
  931. #else
  932.     #define AfxAllocTaskString(x) AfxAllocTaskAnsiString(x)
  933. #endif
  934.  
  935. #ifdef OLE2ANSI
  936.     #define AfxAllocTaskOleString(x) AfxAllocTaskAnsiString(x)
  937. #else
  938.     #define AfxAllocTaskOleString(x) AfxAllocTaskWideString(x)
  939. #endif
  940.  
  941. HRESULT AFXAPI AfxGetClassIDFromString(LPCTSTR lpsz, LPCLSID lpClsID);
  942.  
  943. /////////////////////////////////////////////////////////////////////////////
  944. // Special in-proc server APIs
  945.  
  946. SCODE AFXAPI AfxDllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv);
  947. SCODE AFXAPI AfxDllCanUnloadNow(void);
  948.  
  949. /////////////////////////////////////////////////////////////////////////////
  950. // COleVariant class helpers
  951.  
  952. #define AFX_OLE_TRUE (-1)
  953. #define AFX_OLE_FALSE 0
  954.  
  955. class CLongBinary;  // forward reference (see afxdb_.h)
  956.  
  957. //TO DO: challenge this
  958. #if defined(_WIN32_WCE)  
  959. // WinCE: Bring in CLongBinary from afxdb_.h 
  960. #include "afxdb_.h"
  961. #endif // _WIN32_WCE
  962. /////////////////////////////////////////////////////////////////////////////
  963. // COleVariant class - wraps VARIANT types
  964.  
  965. typedef const VARIANT* LPCVARIANT;
  966.  
  967. class COleVariant : public tagVARIANT
  968. {
  969. // Constructors
  970. public:
  971.     COleVariant();
  972.  
  973.     COleVariant(const VARIANT& varSrc);
  974.     COleVariant(LPCVARIANT pSrc);
  975.     COleVariant(const COleVariant& varSrc);
  976.  
  977.     COleVariant(LPCTSTR lpszSrc);
  978.     COleVariant(LPCTSTR lpszSrc, VARTYPE vtSrc); // used to set to ANSI string
  979.     COleVariant(CString& strSrc);
  980.  
  981.     COleVariant(BYTE nSrc);
  982.     COleVariant(short nSrc, VARTYPE vtSrc = VT_I2);
  983.     COleVariant(long lSrc, VARTYPE vtSrc = VT_I4);
  984.     COleVariant(const COleCurrency& curSrc);
  985.  
  986.     COleVariant(float fltSrc);
  987.     COleVariant(double dblSrc);
  988.     COleVariant(const COleDateTime& timeSrc);
  989.  
  990.     COleVariant(const CByteArray& arrSrc);
  991.     COleVariant(const CLongBinary& lbSrc);
  992.  
  993. WCE_DEL COleVariant(LPCITEMIDLIST pidl);
  994.  
  995. // Operations
  996. public:
  997.     void Clear();
  998.     void ChangeType(VARTYPE vartype, LPVARIANT pSrc = NULL);
  999.     void Attach(VARIANT& varSrc);
  1000.     VARIANT Detach();
  1001.  
  1002.     BOOL operator==(const VARIANT& varSrc) const;
  1003.     BOOL operator==(LPCVARIANT pSrc) const;
  1004.  
  1005.     const COleVariant& operator=(const VARIANT& varSrc);
  1006.     const COleVariant& operator=(LPCVARIANT pSrc);
  1007.     const COleVariant& operator=(const COleVariant& varSrc);
  1008.  
  1009.     const COleVariant& operator=(const LPCTSTR lpszSrc);
  1010.     const COleVariant& operator=(const CString& strSrc);
  1011.  
  1012.     const COleVariant& operator=(BYTE nSrc);
  1013.     const COleVariant& operator=(short nSrc);
  1014.     const COleVariant& operator=(long lSrc);
  1015.     const COleVariant& operator=(const COleCurrency& curSrc);
  1016.  
  1017.     const COleVariant& operator=(float fltSrc);
  1018.     const COleVariant& operator=(double dblSrc);
  1019.     const COleVariant& operator=(const COleDateTime& dateSrc);
  1020.  
  1021.     const COleVariant& operator=(const CByteArray& arrSrc);
  1022.     const COleVariant& operator=(const CLongBinary& lbSrc);
  1023.  
  1024.     void SetString(LPCTSTR lpszSrc, VARTYPE vtSrc); // used to set ANSI string
  1025.  
  1026.     operator LPVARIANT();
  1027.     operator LPCVARIANT() const;
  1028.  
  1029. // Implementation
  1030. public:
  1031.     ~COleVariant();
  1032.     void _ClearCompat();
  1033. };
  1034.  
  1035. // COleVariant diagnostics and serialization
  1036. #ifdef _DEBUG
  1037. CDumpContext& AFXAPI operator<<(CDumpContext& dc, COleVariant varSrc);
  1038. #endif
  1039. CArchive& AFXAPI operator<<(CArchive& ar, COleVariant varSrc);
  1040. CArchive& AFXAPI operator>>(CArchive& ar, COleVariant& varSrc);
  1041.  
  1042. // Helper for initializing VARIANT structures
  1043. void AFXAPI AfxVariantInit(LPVARIANT pVar);
  1044.  
  1045. /////////////////////////////////////////////////////////////////////////////
  1046. // COleCurrency class
  1047.  
  1048. class COleCurrency
  1049. {
  1050. // Constructors
  1051. public:
  1052.     COleCurrency();
  1053.  
  1054.     COleCurrency(CURRENCY cySrc);
  1055.     COleCurrency(const COleCurrency& curSrc);
  1056.     COleCurrency(const VARIANT& varSrc);
  1057.     COleCurrency(long nUnits, long nFractionalUnits);
  1058.  
  1059. // Attributes
  1060. public:
  1061.     enum CurrencyStatus
  1062.     {
  1063.         valid = 0,
  1064.         invalid = 1,    // Invalid currency (overflow, div 0, etc.)
  1065.         null = 2,       // Literally has no value
  1066.     };
  1067.  
  1068.     CURRENCY m_cur;
  1069.     CurrencyStatus m_status;
  1070.  
  1071.     void SetStatus(CurrencyStatus status);
  1072.     CurrencyStatus GetStatus() const;
  1073.  
  1074. // Operations
  1075. public:
  1076.     const COleCurrency& operator=(CURRENCY cySrc);
  1077.     const COleCurrency& operator=(const COleCurrency& curSrc);
  1078.     const COleCurrency& operator=(const VARIANT& varSrc);
  1079.  
  1080.     BOOL operator==(const COleCurrency& cur) const;
  1081.     BOOL operator!=(const COleCurrency& cur) const;
  1082.     BOOL operator<(const COleCurrency& cur) const;
  1083.     BOOL operator>(const COleCurrency& cur) const;
  1084.     BOOL operator<=(const COleCurrency& cur) const;
  1085.     BOOL operator>=(const COleCurrency& cur) const;
  1086.  
  1087.     // Currency math
  1088.     COleCurrency operator+(const COleCurrency& cur) const;
  1089.     COleCurrency operator-(const COleCurrency& cur) const;
  1090.     const COleCurrency& operator+=(const COleCurrency& cur);
  1091.     const COleCurrency& operator-=(const COleCurrency& cur);
  1092.     COleCurrency operator-() const;
  1093.  
  1094.     COleCurrency operator*(long nOperand) const;
  1095.     COleCurrency operator/(long nOperand) const;
  1096.     const COleCurrency& operator*=(long nOperand);
  1097.     const COleCurrency& operator/=(long nOperand);
  1098.  
  1099.     operator CURRENCY() const;
  1100.  
  1101.     // Currency definition
  1102.     void SetCurrency(long nUnits, long nFractionalUnits);
  1103.     BOOL ParseCurrency(LPCTSTR lpszCurrency, DWORD dwFlags = 0,
  1104.         LCID = LANG_USER_DEFAULT);
  1105.  
  1106.     // formatting
  1107.     CString Format(DWORD dwFlags = 0, LCID lcid = LANG_USER_DEFAULT) const;
  1108. };
  1109.  
  1110. // COleCurrency diagnostics and serialization
  1111. #ifdef _DEBUG
  1112. CDumpContext& AFXAPI operator<<(CDumpContext& dc, COleCurrency curSrc);
  1113. #endif
  1114. CArchive& AFXAPI operator<<(CArchive& ar, COleCurrency curSrc);
  1115. CArchive& AFXAPI operator>>(CArchive& ar, COleCurrency& curSrc);
  1116.  
  1117. /////////////////////////////////////////////////////////////////////////////
  1118. // COleDateTime class helpers
  1119.  
  1120. #define AFX_OLE_DATETIME_ERROR (-1)
  1121. #define AFX_OLE_DATETIME_HALFSECOND (1.0 / (2.0 * (60.0 * 60.0 * 24.0)))
  1122.  
  1123. /////////////////////////////////////////////////////////////////////////////
  1124. // COleDateTime class
  1125.  
  1126. class COleDateTime
  1127. {
  1128. // Constructors
  1129. public:
  1130.     static COleDateTime PASCAL GetCurrentTime();
  1131.  
  1132.     COleDateTime();
  1133.  
  1134.     COleDateTime(const COleDateTime& dateSrc);
  1135.     COleDateTime(const VARIANT& varSrc);
  1136.     COleDateTime(DATE dtSrc);
  1137.  
  1138.     COleDateTime(time_t timeSrc);
  1139.     COleDateTime(const SYSTEMTIME& systimeSrc);
  1140.     COleDateTime(const FILETIME& filetimeSrc);
  1141.  
  1142.     COleDateTime(int nYear, int nMonth, int nDay,
  1143.         int nHour, int nMin, int nSec);
  1144. WCE_DEL    COleDateTime(WORD wDosDate, WORD wDosTime);
  1145.  
  1146. // Attributes
  1147. public:
  1148.     enum DateTimeStatus
  1149.     {
  1150.         valid = 0,
  1151.         invalid = 1,    // Invalid date (out of range, etc.)
  1152.         null = 2,       // Literally has no value
  1153.     };
  1154.  
  1155.     DATE m_dt;
  1156.     DateTimeStatus m_status;
  1157.  
  1158.     void SetStatus(DateTimeStatus status);
  1159.     DateTimeStatus GetStatus() const;
  1160.  
  1161.     BOOL GetAsSystemTime(SYSTEMTIME& sysTime) const;
  1162.  
  1163.     int GetYear() const;
  1164.     int GetMonth() const;       // month of year (1 = Jan)
  1165.     int GetDay() const;         // day of month (0-31)
  1166.     int GetHour() const;        // hour in day (0-23)
  1167.     int GetMinute() const;      // minute in hour (0-59)
  1168.     int GetSecond() const;      // second in minute (0-59)
  1169.     int GetDayOfWeek() const;   // 1=Sun, 2=Mon, ..., 7=Sat
  1170.     int GetDayOfYear() const;   // days since start of year, Jan 1 = 1
  1171.  
  1172. // Operations
  1173. public:
  1174.     const COleDateTime& operator=(const COleDateTime& dateSrc);
  1175.     const COleDateTime& operator=(const VARIANT& varSrc);
  1176.     const COleDateTime& operator=(DATE dtSrc);
  1177.  
  1178.     const COleDateTime& operator=(const time_t& timeSrc);
  1179.     const COleDateTime& operator=(const SYSTEMTIME& systimeSrc);
  1180.     const COleDateTime& operator=(const FILETIME& filetimeSrc);
  1181.  
  1182.     BOOL operator==(const COleDateTime& date) const;
  1183.     BOOL operator!=(const COleDateTime& date) const;
  1184.     BOOL operator<(const COleDateTime& date) const;
  1185.     BOOL operator>(const COleDateTime& date) const;
  1186.     BOOL operator<=(const COleDateTime& date) const;
  1187.     BOOL operator>=(const COleDateTime& date) const;
  1188.  
  1189.     // DateTime math
  1190.     COleDateTime operator+(const COleDateTimeSpan& dateSpan) const;
  1191.     COleDateTime operator-(const COleDateTimeSpan& dateSpan) const;
  1192.     const COleDateTime& operator+=(const COleDateTimeSpan dateSpan);
  1193.     const COleDateTime& operator-=(const COleDateTimeSpan dateSpan);
  1194.  
  1195.     // DateTimeSpan math
  1196.     COleDateTimeSpan operator-(const COleDateTime& date) const;
  1197.  
  1198.     operator DATE() const;
  1199.  
  1200.     int SetDateTime(int nYear, int nMonth, int nDay,
  1201.         int nHour, int nMin, int nSec);
  1202.     int SetDate(int nYear, int nMonth, int nDay);
  1203.     int SetTime(int nHour, int nMin, int nSec);
  1204.     BOOL ParseDateTime(LPCTSTR lpszDate, DWORD dwFlags = 0,
  1205.         LCID lcid = LANG_USER_DEFAULT);
  1206.  
  1207.     // formatting
  1208.     CString Format(DWORD dwFlags = 0, LCID lcid = LANG_USER_DEFAULT) const;
  1209. WCE_DEL    CString Format(LPCTSTR lpszFormat) const;
  1210. WCE_DEL    CString Format(UINT nFormatID) const;
  1211.  
  1212. // Implementation
  1213. protected:
  1214.     void CheckRange();
  1215.     friend COleDateTimeSpan;
  1216. };
  1217.  
  1218. // COleDateTime diagnostics and serialization
  1219. #ifdef _DEBUG
  1220. CDumpContext& AFXAPI operator<<(CDumpContext& dc, COleDateTime dateSrc);
  1221. #endif
  1222. CArchive& AFXAPI operator<<(CArchive& ar, COleDateTime dateSrc);
  1223. CArchive& AFXAPI operator>>(CArchive& ar, COleDateTime& dateSrc);
  1224.  
  1225. /////////////////////////////////////////////////////////////////////////////
  1226. // COleDateTimeSpan class
  1227. class COleDateTimeSpan
  1228. {
  1229. // Constructors
  1230. public:
  1231.     COleDateTimeSpan();
  1232.  
  1233.     COleDateTimeSpan(double dblSpanSrc);
  1234.     COleDateTimeSpan(const COleDateTimeSpan& dateSpanSrc);
  1235.     COleDateTimeSpan(long lDays, int nHours, int nMins, int nSecs);
  1236.  
  1237. // Attributes
  1238. public:
  1239.     enum DateTimeSpanStatus
  1240.     {
  1241.         valid = 0,
  1242.         invalid = 1,    // Invalid span (out of range, etc.)
  1243.         null = 2,       // Literally has no value
  1244.     };
  1245.  
  1246.     double m_span;
  1247.     DateTimeSpanStatus m_status;
  1248.  
  1249.     void SetStatus(DateTimeSpanStatus status);
  1250.     DateTimeSpanStatus GetStatus() const;
  1251.  
  1252.     double GetTotalDays() const;    // span in days (about -3.65e6 to 3.65e6)
  1253.     double GetTotalHours() const;   // span in hours (about -8.77e7 to 8.77e6)
  1254.     double GetTotalMinutes() const; // span in minutes (about -5.26e9 to 5.26e9)
  1255.     double GetTotalSeconds() const; // span in seconds (about -3.16e11 to 3.16e11)
  1256.  
  1257.     long GetDays() const;       // component days in span
  1258.     long GetHours() const;      // component hours in span (-23 to 23)
  1259.     long GetMinutes() const;    // component minutes in span (-59 to 59)
  1260.     long GetSeconds() const;    // component seconds in span (-59 to 59)
  1261.  
  1262. // Operations
  1263. public:
  1264.     const COleDateTimeSpan& operator=(double dblSpanSrc);
  1265.     const COleDateTimeSpan& operator=(const COleDateTimeSpan& dateSpanSrc);
  1266.  
  1267.     BOOL operator==(const COleDateTimeSpan& dateSpan) const;
  1268.     BOOL operator!=(const COleDateTimeSpan& dateSpan) const;
  1269.     BOOL operator<(const COleDateTimeSpan& dateSpan) const;
  1270.     BOOL operator>(const COleDateTimeSpan& dateSpan) const;
  1271.     BOOL operator<=(const COleDateTimeSpan& dateSpan) const;
  1272.     BOOL operator>=(const COleDateTimeSpan& dateSpan) const;
  1273.  
  1274.     // DateTimeSpan math
  1275.     COleDateTimeSpan operator+(const COleDateTimeSpan& dateSpan) const;
  1276.     COleDateTimeSpan operator-(const COleDateTimeSpan& dateSpan) const;
  1277.     const COleDateTimeSpan& operator+=(const COleDateTimeSpan dateSpan);
  1278.     const COleDateTimeSpan& operator-=(const COleDateTimeSpan dateSpan);
  1279.     COleDateTimeSpan operator-() const;
  1280.  
  1281.     operator double() const;
  1282.  
  1283.     void SetDateTimeSpan(long lDays, int nHours, int nMins, int nSecs);
  1284.  
  1285.     // formatting
  1286. WCE_DEL    CString Format(LPCTSTR pFormat) const;
  1287. WCE_DEL    CString Format(UINT nID) const;
  1288.  
  1289. // Implementation
  1290. public:
  1291.     void CheckRange();
  1292.     friend COleDateTime;
  1293. };
  1294.  
  1295. // COleDateTimeSpan diagnostics and serialization
  1296. #ifdef _DEBUG
  1297. CDumpContext& AFXAPI operator<<(CDumpContext& dc,COleDateTimeSpan dateSpanSrc);
  1298. #endif
  1299. CArchive& AFXAPI operator<<(CArchive& ar, COleDateTimeSpan dateSpanSrc);
  1300. CArchive& AFXAPI operator>>(CArchive& ar, COleDateTimeSpan& dateSpanSrc);
  1301.  
  1302. /////////////////////////////////////////////////////////////////////////////
  1303. // Helper for initializing COleSafeArray
  1304. void AFXAPI AfxSafeArrayInit(COleSafeArray* psa);
  1305.  
  1306. /////////////////////////////////////////////////////////////////////////////
  1307. // CSafeArray class
  1308.  
  1309. typedef const SAFEARRAY* LPCSAFEARRAY;
  1310.  
  1311. class COleSafeArray : public tagVARIANT
  1312. {
  1313. //Constructors
  1314. public:
  1315.     COleSafeArray();
  1316.     COleSafeArray(const SAFEARRAY& saSrc, VARTYPE vtSrc);
  1317.     COleSafeArray(LPCSAFEARRAY pSrc, VARTYPE vtSrc);
  1318.     COleSafeArray(const COleSafeArray& saSrc);
  1319.     COleSafeArray(const VARIANT& varSrc);
  1320.     COleSafeArray(LPCVARIANT pSrc);
  1321.     COleSafeArray(const COleVariant& varSrc);
  1322.  
  1323. // Operations
  1324. public:
  1325.     void Clear();
  1326.     void Attach(VARIANT& varSrc);
  1327.     VARIANT Detach();
  1328.  
  1329.     COleSafeArray& operator=(const COleSafeArray& saSrc);
  1330.     COleSafeArray& operator=(const VARIANT& varSrc);
  1331.     COleSafeArray& operator=(LPCVARIANT pSrc);
  1332.     COleSafeArray& operator=(const COleVariant& varSrc);
  1333.  
  1334.     BOOL operator==(const SAFEARRAY& saSrc) const;
  1335.     BOOL operator==(LPCSAFEARRAY pSrc) const;
  1336.     BOOL operator==(const COleSafeArray& saSrc) const;
  1337.     BOOL operator==(const VARIANT& varSrc) const;
  1338.     BOOL operator==(LPCVARIANT pSrc) const;
  1339.     BOOL operator==(const COleVariant& varSrc) const;
  1340.  
  1341.     operator LPVARIANT();
  1342.     operator LPCVARIANT() const;
  1343.  
  1344.     // One dim array helpers
  1345.     void CreateOneDim(VARTYPE vtSrc, DWORD dwElements,
  1346.         const void* pvSrcData = NULL, long nLBound = 0);
  1347.     DWORD GetOneDimSize();
  1348.     void ResizeOneDim(DWORD dwElements);
  1349.  
  1350.     // Multi dim array helpers
  1351.     void Create(VARTYPE vtSrc, DWORD dwDims, DWORD* rgElements);
  1352.  
  1353.     // SafeArray wrapper classes
  1354.     void Create(VARTYPE vtSrc, DWORD dwDims, SAFEARRAYBOUND* rgsabounds);
  1355.     void AccessData(void** ppvData);
  1356.     void UnaccessData();
  1357.     void AllocData();
  1358.     void AllocDescriptor(DWORD dwDims);
  1359.     void Copy(LPSAFEARRAY* ppsa);
  1360.     void GetLBound(DWORD dwDim, long* pLBound);
  1361.     void GetUBound(DWORD dwDim, long* pUBound);
  1362.     void GetElement(long* rgIndices, void* pvData);
  1363.     void PtrOfIndex(long* rgIndices, void** ppvData);
  1364.     void PutElement(long* rgIndices, void* pvData);
  1365.     void Redim(SAFEARRAYBOUND* psaboundNew);
  1366.     void Lock();
  1367.     void Unlock();
  1368.     DWORD GetDim();
  1369.     DWORD GetElemSize();
  1370.     void Destroy();
  1371.     void DestroyData();
  1372.     void DestroyDescriptor();
  1373.  
  1374. //Implementation
  1375. public:
  1376.     ~COleSafeArray();
  1377.  
  1378.     // Cache info to make element access (operator []) faster
  1379.     DWORD m_dwElementSize;
  1380.     DWORD m_dwDims;
  1381. };
  1382.  
  1383. // COleSafeArray diagnostics and serialization
  1384. #ifdef _DEBUG
  1385. CDumpContext& AFXAPI operator<<(CDumpContext& dc, COleSafeArray& saSrc);
  1386. #endif
  1387.  
  1388. /////////////////////////////////////////////////////////////////////////////
  1389. // DDX_ functions for OLE controls on dialogs
  1390.  
  1391. #ifndef _AFX_NO_OCC_SUPPORT
  1392.  
  1393. void AFXAPI DDX_OCText(CDataExchange* pDX, int nIDC, DISPID dispid,
  1394.     CString& value);
  1395. void AFXAPI DDX_OCTextRO(CDataExchange* pDX, int nIDC, DISPID dispid,
  1396.     CString& value);
  1397. void AFXAPI DDX_OCBool(CDataExchange* pDX, int nIDC, DISPID dispid,
  1398.     BOOL& value);
  1399. void AFXAPI DDX_OCBoolRO(CDataExchange* pDX, int nIDC, DISPID dispid,
  1400.     BOOL& value);
  1401. void AFXAPI DDX_OCInt(CDataExchange* pDX, int nIDC, DISPID dispid,
  1402.     int &value);
  1403. void AFXAPI DDX_OCIntRO(CDataExchange* pDX, int nIDC, DISPID dispid,
  1404.     int &value);
  1405. void AFXAPI DDX_OCInt(CDataExchange* pDX, int nIDC, DISPID dispid,
  1406.     long &value);
  1407. void AFXAPI DDX_OCIntRO(CDataExchange* pDX, int nIDC, DISPID dispid,
  1408.     long &value);
  1409. void AFXAPI DDX_OCShort(CDataExchange* pDX, int nIDC, DISPID dispid,
  1410.     short& value);
  1411. void AFXAPI DDX_OCShortRO(CDataExchange* pDX, int nIDC, DISPID dispid,
  1412.     short& value);
  1413. void AFXAPI DDX_OCColor(CDataExchange* pDX, int nIDC, DISPID dispid,
  1414.     OLE_COLOR& value);
  1415. void AFXAPI DDX_OCColorRO(CDataExchange* pDX, int nIDC, DISPID dispid,
  1416.     OLE_COLOR& value);
  1417. void AFXAPI DDX_OCFloat(CDataExchange* pDX, int nIDC, DISPID dispid,
  1418.     float& value);
  1419. void AFXAPI DDX_OCFloatRO(CDataExchange* pDX, int nIDC, DISPID dispid,
  1420.     float& value);
  1421. void AFXAPI DDX_OCFloat(CDataExchange* pDX, int nIDC, DISPID dispid,
  1422.     double& value);
  1423. void AFXAPI DDX_OCFloatRO(CDataExchange* pDX, int nIDC, DISPID dispid,
  1424.     double& value);
  1425.  
  1426. #endif // !_AFX_NO_OCC_SUPPORT
  1427.  
  1428. /////////////////////////////////////////////////////////////////////////////
  1429. // Function to enable containment of OLE controls
  1430.  
  1431. #ifndef _AFX_NO_OCC_SUPPORT
  1432. void AFX_CDECL AfxEnableControlContainer(COccManager* pOccManager=NULL);
  1433. #else
  1434. #define AfxEnableControlContainer()
  1435. #endif
  1436.  
  1437. /////////////////////////////////////////////////////////////////////////////
  1438. // Inline function declarations
  1439.  
  1440. #ifdef _AFX_PACKING
  1441. #pragma pack(pop)
  1442. #endif
  1443.  
  1444. #ifdef _AFX_ENABLE_INLINES
  1445. #define _AFXDISP_INLINE AFX_INLINE
  1446. #include <afxole.inl>
  1447. #undef _AFXDISP_INLINE
  1448. #endif
  1449.  
  1450. #undef AFX_DATA
  1451. #define AFX_DATA
  1452.  
  1453. #ifdef _AFX_MINREBUILD
  1454. #pragma component(minrebuild, on)
  1455. #endif
  1456. #ifndef _AFX_FULLTYPEINFO
  1457. #pragma component(mintypeinfo, off)
  1458. #endif
  1459.  
  1460. #endif //__AFXDISP_H__
  1461.  
  1462. /////////////////////////////////////////////////////////////////////////////
  1463.