home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / vc98 / mfc / src / occddx.cpp < prev    next >
C/C++ Source or Header  |  1998-06-16  |  4KB  |  143 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. #include "stdafx.h"
  12. #include "occimpl.h"
  13.  
  14. #ifdef AFX_OCC_SEG
  15. #pragma code_seg(AFX_OCC_SEG)
  16. #endif
  17.  
  18. #ifdef _DEBUG
  19. #undef THIS_FILE
  20. static char THIS_FILE[] = __FILE__;
  21. #endif
  22.  
  23. #define new DEBUG_NEW
  24.  
  25. #ifndef _AFX_NO_OCC_SUPPORT
  26.  
  27. /////////////////////////////////////////////////////////////////////////////
  28. // Private helper for read-only property exchange with OLE controls
  29.  
  30. static void DDX_OCPropertyRO(CDataExchange* pDX, int nIDC,
  31.     DISPID dispid, VARTYPE vt, void* pValue)
  32. {
  33.     if (pDX->m_bSaveAndValidate)
  34.     {
  35.         CWnd* pControl = pDX->PrepareOleCtrl(nIDC);
  36.         pControl->GetProperty(dispid, vt, pValue);
  37.     }
  38. }
  39.  
  40. /////////////////////////////////////////////////////////////////////////////
  41. // Simple formatting to text item
  42.  
  43. void AFXAPI DDX_OCText(CDataExchange* pDX, int nIDC, DISPID dispid,
  44.     CString& value)
  45. {
  46.     CWnd* pControl = pDX->PrepareOleCtrl(nIDC);
  47.     if (pDX->m_bSaveAndValidate)
  48.         pControl->GetProperty(dispid, VT_BSTR, &value);
  49.     else
  50.         pControl->SetProperty(dispid, VT_BSTR, (LPCTSTR)value);
  51. }
  52.  
  53. void AFXAPI DDX_OCTextRO(CDataExchange* pDX, int nIDC, DISPID dispid,
  54.     CString& value)
  55. {
  56.     DDX_OCPropertyRO(pDX, nIDC, dispid, VT_BSTR, &value);
  57. }
  58.  
  59. /////////////////////////////////////////////////////////////////////////////
  60. // non-text properties
  61.  
  62. void AFXAPI DDX_OCBool(CDataExchange* pDX, int nIDC, DISPID dispid,
  63.     BOOL& value)
  64. {
  65.     CWnd* pControl = pDX->PrepareOleCtrl(nIDC);
  66.     if (pDX->m_bSaveAndValidate)
  67.         pControl->GetProperty(dispid, VT_BOOL, &value);
  68.     else
  69.         pControl->SetProperty(dispid, VT_BOOL, value);
  70. }
  71.  
  72. void AFXAPI DDX_OCBoolRO(CDataExchange* pDX, int nIDC, DISPID dispid,
  73.     BOOL& value)
  74. {
  75.     DDX_OCPropertyRO(pDX, nIDC, dispid, VT_BOOL, &value);
  76. }
  77.  
  78. void AFXAPI DDX_OCInt(CDataExchange* pDX, int nIDC, DISPID dispid,
  79.     int &value)
  80. {
  81.     CWnd* pControl = pDX->PrepareOleCtrl(nIDC);
  82.     if (pDX->m_bSaveAndValidate)
  83.         pControl->GetProperty(dispid, VT_I4, &value);
  84.     else
  85.         pControl->SetProperty(dispid, VT_I4, value);
  86. }
  87.  
  88. void AFXAPI DDX_OCIntRO(CDataExchange* pDX, int nIDC, DISPID dispid,
  89.     int &value)
  90. {
  91.     DDX_OCPropertyRO(pDX, nIDC, dispid, VT_I4, &value);
  92. }
  93.  
  94. void AFXAPI DDX_OCInt(CDataExchange* pDX, int nIDC, DISPID dispid,
  95.     long &value)
  96. {
  97.     CWnd* pControl = pDX->PrepareOleCtrl(nIDC);
  98.     if (pDX->m_bSaveAndValidate)
  99.         pControl->GetProperty(dispid, VT_I4, &value);
  100.     else
  101.         pControl->SetProperty(dispid, VT_I4, value);
  102. }
  103.  
  104. void AFXAPI DDX_OCIntRO(CDataExchange* pDX, int nIDC, DISPID dispid,
  105.     long &value)
  106. {
  107.     DDX_OCPropertyRO(pDX, nIDC, dispid, VT_I4, &value);
  108. }
  109.  
  110. void AFXAPI DDX_OCShort(CDataExchange* pDX, int nIDC, DISPID dispid,
  111.     short& value)
  112. {
  113.     CWnd* pControl = pDX->PrepareOleCtrl(nIDC);
  114.     if (pDX->m_bSaveAndValidate)
  115.         pControl->GetProperty(dispid, VT_I2, &value);
  116.     else
  117.         pControl->SetProperty(dispid, VT_I2, value);
  118. }
  119.  
  120. void AFXAPI DDX_OCShortRO(CDataExchange* pDX, int nIDC, DISPID dispid,
  121.     short& value)
  122. {
  123.     DDX_OCPropertyRO(pDX, nIDC, dispid, VT_I2, &value);
  124. }
  125.  
  126. void AFXAPI DDX_OCColor(CDataExchange* pDX, int nIDC, DISPID dispid,
  127.     OLE_COLOR& value)
  128. {
  129.     CWnd* pControl = pDX->PrepareOleCtrl(nIDC);
  130.     if (pDX->m_bSaveAndValidate)
  131.         pControl->GetProperty(dispid, VT_COLOR, &value);
  132.     else
  133.         pControl->SetProperty(dispid, VT_COLOR, value);
  134. }
  135.  
  136. void AFXAPI DDX_OCColorRO(CDataExchange* pDX, int nIDC, DISPID dispid,
  137.     OLE_COLOR& value)
  138. {
  139.     DDX_OCPropertyRO(pDX, nIDC, dispid, VT_COLOR, &value);
  140. }
  141.  
  142. #endif // !_AFX_NO_OCC_SUPPORT
  143.