Listing 1: Pixel.cpp
Implementation of CPixel
// Pixel.cpp : Implementation of CPixel #include "stdafx.h" #include "Picture.h" #include "Pixel.h" ///////////////////////////////////////////////////////////////////////////// // CPixel STDMETHODIMP CPixel::get_Color(baseColors *pVal) { *pVal = m_color; return S_OK; } STDMETHODIMP CPixel::put_Color(baseColors newVal) { HRESULT hr = S_OK; // Test if the new color is valid or not if (newVal < 0 || newVal > 15) return AtlReportError(CLSID_Pixel, IDS_BAD_COLOR, IID_IPixel, 0, _Module.GetModuleInstance()); if (SUCCEEDED(hr = IsReadOnly())) m_color = newVal; return hr; } STDMETHODIMP CPixel::get_Row(long *pVal) { *pVal = m_row; return S_OK; } STDMETHODIMP CPixel::put_Row(long newVal) { HRESULT hr = S_OK; if (SUCCEEDED(hr = IsReadOnly())) m_row = newVal; return hr; } STDMETHODIMP CPixel::get_Column(long *pVal) { *pVal = m_col; return S_OK; } STDMETHODIMP CPixel::put_Column(long newVal) { HRESULT hr = S_OK; if (SUCCEEDED(hr = IsReadOnly())) m_col = newVal; return hr; } HRESULT CPixel::IsReadOnly() { // Test if this pixel is in readonly mode if (m_bReadOnly) return AtlReportError(CLSID_Pixel, IDS_READONLY_PIXEL, IID_IPixel, 0, _Module.GetModuleInstance()); else return S_OK; } //End of File