home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / com / labrador / labobj.cpp next >
C/C++ Source or Header  |  1998-04-02  |  2KB  |  79 lines

  1. // LabObj.cpp : Implementation of CLabradorApp and DLL registration.
  2. //
  3. // This is a part of the ActiveX Template Library.
  4. // Copyright (C) 1996 Microsoft Corporation
  5. // All rights reserved.
  6. //
  7. // This source code is only intended as a supplement to the
  8. // ActiveX Template Library Reference and related
  9. // electronic documentation provided with the library.
  10. // See these sources for detailed information regarding the
  11. // ActiveX Template Library product.
  12.  
  13. #include "prelab.h"
  14. #include "Labrador.h"
  15. #include "LabObj.h"
  16. #include <wchar.h>
  17.  
  18.  
  19. /////////////////////////////////////////////////////////////////////////////
  20. //  CLabrador Interface Implementation
  21.  
  22. CLabrador::CLabrador()
  23. {
  24.     wcscpy(m_szPetName, L"Fido");
  25.     wcscpy(m_szSpeciesName, L"Warthog");
  26.     m_bIsAlive = TRUE;
  27.     m_bIsBarking = FALSE;
  28. }
  29.  
  30. /////////////////////////////////////////////////////////////////////////////
  31. //  IDog Implementation
  32.  
  33. STDMETHODIMP CLabrador::GetPetName(MY_BSTR pStr)
  34. {
  35.     if (pStr)
  36.         wcscpy(pStr, m_szPetName);
  37.     return (HRESULT)NOERROR;
  38. }
  39.  
  40. STDMETHODIMP CLabrador::SetPetName(MY_BSTR pStr)
  41. {
  42.     if (pStr)
  43.     {
  44.         wcscpy(m_szPetName, pStr);
  45.         return S_OK;
  46.     }
  47.     return E_POINTER;
  48. }
  49.  
  50. STDMETHODIMP CLabrador::IsBarking(BOOL* pBool)
  51. {
  52.     if (pBool)
  53.     {
  54.         *pBool = m_bIsBarking;
  55.         return S_OK;
  56.     }
  57.     return E_POINTER;
  58. }
  59.  
  60. /////////////////////////////////////////////////////////////////////////////
  61. //  IMammal Implementation
  62.  
  63. STDMETHODIMP CLabrador::GetSpeciesName(MY_BSTR pStr)
  64. {
  65.     if (pStr != NULL)
  66.         wcscpy(pStr, m_szSpeciesName);
  67.     return (HRESULT)NOERROR;
  68. }
  69.  
  70. STDMETHODIMP CLabrador::IsAlive(BOOL* pBool)
  71. {
  72.     if (pBool)
  73.     {
  74.         *pBool = m_bIsAlive;
  75.         return S_OK;
  76.     }
  77.     return E_POINTER;
  78. }
  79.