home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / mfc / ole / tstcon / aprop.cpp next >
Encoding:
C/C++ Source or Header  |  1998-03-27  |  1.7 KB  |  102 lines

  1. #include "StdAfx.H"
  2. #include "TestCon.H"
  3.  
  4. #ifdef _DEBUG
  5. #define new DEBUG_NEW
  6. #undef THIS_FILE
  7. static char THIS_FILE[] = __FILE__;
  8. #endif
  9.  
  10.  
  11. IMPLEMENT_SERIAL( CAmbientProperty, CObject, 1 );
  12.  
  13. CAmbientProperty::CAmbientProperty() :
  14.    m_dispid( 0 ),
  15.    m_tEnabled( FALSE )
  16. {
  17. }
  18.  
  19. CAmbientProperty::CAmbientProperty( DISPID dispid, LPCTSTR pszName,
  20.    const VARIANT& var, int vti, BOOL tStock ) :
  21.    m_dispid( dispid ),
  22.    m_strName( pszName ),
  23.    m_varValue( var ),
  24.    m_vti( vti ),
  25.    m_tEnabled( TRUE ),
  26.    m_tStock( tStock )
  27. {
  28. }
  29.  
  30. void CAmbientProperty::Enable( BOOL tEnabled )
  31. {
  32.    m_tEnabled = tEnabled;
  33. }
  34.  
  35. DISPID CAmbientProperty::GetID() const
  36. {
  37.    return( m_dispid );
  38. }
  39.  
  40. CString CAmbientProperty::GetName() const
  41. {
  42.    return( m_strName );
  43. }
  44.  
  45. const COleVariant& CAmbientProperty::GetValue() const
  46. {
  47.    return( m_varValue );
  48. }
  49.  
  50. int CAmbientProperty::GetVTI() const
  51. {
  52.    return( m_vti );
  53. }
  54.  
  55. BOOL CAmbientProperty::IsEnabled() const
  56. {
  57.    return( m_tEnabled );
  58. }
  59.  
  60. BOOL CAmbientProperty::IsStock() const
  61. {
  62.    return( m_tStock );
  63. }
  64.  
  65. void CAmbientProperty::SetValue( const VARIANT& varValue, int vti )
  66. {
  67.    m_varValue = varValue;
  68.    if( vti == -1 )
  69.    {
  70.       m_vti = VTToVTI( varValue.vt );
  71.    }
  72.    else
  73.    {
  74.       ASSERT( VTIToVT( vti ) == varValue.vt );
  75.       m_vti = vti;
  76.    }
  77. }
  78.  
  79. void CAmbientProperty::Serialize( CArchive& ar )
  80. {
  81.    CObject::Serialize( ar );
  82.  
  83.    if( ar.IsStoring() )
  84.    {
  85.       ar<<m_dispid;
  86.       ar<<m_strName;
  87.       ar<<m_varValue;
  88.       ar<<m_vti;
  89.       ar<<m_tEnabled;
  90.       ar<<m_tStock;
  91.    }
  92.    else
  93.    {
  94.       ar>>m_dispid;
  95.       ar>>m_strName;
  96.       ar>>m_varValue;
  97.       ar>>m_vti;
  98.       ar>>m_tEnabled;
  99.       ar>>m_tStock;
  100.    }
  101. }
  102.