occddx.cpp 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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. #include "stdafx.h"
  11. #include "occimpl.h"
  12. #ifdef AFX_OCC_SEG
  13. #pragma code_seg(AFX_OCC_SEG)
  14. #endif
  15. #ifdef _DEBUG
  16. #undef THIS_FILE
  17. static char THIS_FILE[] = __FILE__;
  18. #endif
  19. #define new DEBUG_NEW
  20. #ifndef _AFX_NO_OCC_SUPPORT
  21. /////////////////////////////////////////////////////////////////////////////
  22. // Private helper for read-only property exchange with OLE controls
  23. static void DDX_OCPropertyRO(CDataExchange* pDX, int nIDC,
  24. DISPID dispid, VARTYPE vt, void* pValue)
  25. {
  26. if (pDX->m_bSaveAndValidate)
  27. {
  28. CWnd* pControl = pDX->PrepareOleCtrl(nIDC);
  29. pControl->GetProperty(dispid, vt, pValue);
  30. }
  31. }
  32. /////////////////////////////////////////////////////////////////////////////
  33. // Simple formatting to text item
  34. void AFXAPI DDX_OCText(CDataExchange* pDX, int nIDC, DISPID dispid,
  35. CString& value)
  36. {
  37. CWnd* pControl = pDX->PrepareOleCtrl(nIDC);
  38. if (pDX->m_bSaveAndValidate)
  39. pControl->GetProperty(dispid, VT_BSTR, &value);
  40. else
  41. pControl->SetProperty(dispid, VT_BSTR, (LPCTSTR)value);
  42. }
  43. void AFXAPI DDX_OCTextRO(CDataExchange* pDX, int nIDC, DISPID dispid,
  44. CString& value)
  45. {
  46. DDX_OCPropertyRO(pDX, nIDC, dispid, VT_BSTR, &value);
  47. }
  48. /////////////////////////////////////////////////////////////////////////////
  49. // non-text properties
  50. void AFXAPI DDX_OCBool(CDataExchange* pDX, int nIDC, DISPID dispid,
  51. BOOL& value)
  52. {
  53. CWnd* pControl = pDX->PrepareOleCtrl(nIDC);
  54. if (pDX->m_bSaveAndValidate)
  55. pControl->GetProperty(dispid, VT_BOOL, &value);
  56. else
  57. pControl->SetProperty(dispid, VT_BOOL, value);
  58. }
  59. void AFXAPI DDX_OCBoolRO(CDataExchange* pDX, int nIDC, DISPID dispid,
  60. BOOL& value)
  61. {
  62. DDX_OCPropertyRO(pDX, nIDC, dispid, VT_BOOL, &value);
  63. }
  64. void AFXAPI DDX_OCInt(CDataExchange* pDX, int nIDC, DISPID dispid,
  65. int &value)
  66. {
  67. CWnd* pControl = pDX->PrepareOleCtrl(nIDC);
  68. if (pDX->m_bSaveAndValidate)
  69. pControl->GetProperty(dispid, VT_I4, &value);
  70. else
  71. pControl->SetProperty(dispid, VT_I4, value);
  72. }
  73. void AFXAPI DDX_OCIntRO(CDataExchange* pDX, int nIDC, DISPID dispid,
  74. int &value)
  75. {
  76. DDX_OCPropertyRO(pDX, nIDC, dispid, VT_I4, &value);
  77. }
  78. void AFXAPI DDX_OCInt(CDataExchange* pDX, int nIDC, DISPID dispid,
  79. long &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. void AFXAPI DDX_OCIntRO(CDataExchange* pDX, int nIDC, DISPID dispid,
  88. long &value)
  89. {
  90. DDX_OCPropertyRO(pDX, nIDC, dispid, VT_I4, &value);
  91. }
  92. void AFXAPI DDX_OCShort(CDataExchange* pDX, int nIDC, DISPID dispid,
  93. short& value)
  94. {
  95. CWnd* pControl = pDX->PrepareOleCtrl(nIDC);
  96. if (pDX->m_bSaveAndValidate)
  97. pControl->GetProperty(dispid, VT_I2, &value);
  98. else
  99. pControl->SetProperty(dispid, VT_I2, value);
  100. }
  101. void AFXAPI DDX_OCShortRO(CDataExchange* pDX, int nIDC, DISPID dispid,
  102. short& value)
  103. {
  104. DDX_OCPropertyRO(pDX, nIDC, dispid, VT_I2, &value);
  105. }
  106. void AFXAPI DDX_OCColor(CDataExchange* pDX, int nIDC, DISPID dispid,
  107. OLE_COLOR& value)
  108. {
  109. CWnd* pControl = pDX->PrepareOleCtrl(nIDC);
  110. if (pDX->m_bSaveAndValidate)
  111. pControl->GetProperty(dispid, VT_COLOR, &value);
  112. else
  113. pControl->SetProperty(dispid, VT_COLOR, value);
  114. }
  115. void AFXAPI DDX_OCColorRO(CDataExchange* pDX, int nIDC, DISPID dispid,
  116. OLE_COLOR& value)
  117. {
  118. DDX_OCPropertyRO(pDX, nIDC, dispid, VT_COLOR, &value);
  119. }
  120. #endif // !_AFX_NO_OCC_SUPPORT