home *** CD-ROM | disk | FTP | other *** search
- /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-
- Copyright (c) 1998 Microsoft Corporation
-
- Module Name:
-
- SimpleClockSink.cpp
-
- Abstract:
-
- Implementation of IUnknown, IASEventSink, and IASClassMsgSink
-
- Environment:
-
- AutoPC
-
- -------------------------------------------------------------------*/
-
- //Non-application header files
- #include <windows.h>
- #include <olectl.h>
- #include <asfc.h> //Header for AS Forms Manager
- #include <ascmnctl.h> //Header for AS Common Controls
- #include <apcdebug.h>
-
- //Application header files
- #include "simpleclock.h"
-
- /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- Function:
- CSimpleClockSink
-
- Description:
- Constructor, sets member variables
-
- Parameters:
- [IN] DWORD dwThreadID - Current process thread ID
- -------------------------------------------------------------------*/
-
- CSimpleClockSink::CSimpleClockSink(DWORD dwThreadID)
- {
- m_dwThreadID = dwThreadID;
- }
-
- /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- Function:
- ~CSimpleClockSink
-
- Description:
- Destructor, does nothing in this case
- -------------------------------------------------------------------*/
-
- CSimpleClockSink::~CSimpleClockSink()
- {
-
- }
-
- /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- Function:
- QueryInterface
-
- Description:
- Returns the requested interface pointer
-
- Parameters:
- [IN] REFIID riid - Interface GUID requested
- [OUT] PVOID *ppv - Pointer to the requested interface
- returns HRESULT status
- -------------------------------------------------------------------*/
-
- STDMETHODIMP
- CSimpleClockSink::QueryInterface(REFIID riid,
- PVOID *ppv)
- {
- HRESULT hr = NOERROR;
-
- if(!ppv) hr = E_INVALIDARG;
-
- if(SUCCEEDED(hr))
- {
- if (riid == IID_ASCLASSMSGSINK) *ppv = (PVOID) (IASClassMsgSink *) this;
- else if (riid == IID_ASEVENTSINK) *ppv = (PVOID) (IASEventSink*) this;
- else if (riid == IID_IUnknown) *ppv = (PVOID) (IUnknown *) (IASClassMsgSink *)this;
- else if (riid == IID_IDispatch) *ppv = (PVOID) (IDispatch *) (IASClassMsgSink *)this;
- else hr = E_NOINTERFACE;
- }
-
- if(SUCCEEDED(hr)) AddRef();
-
- return hr;
- }
-
- /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- Function:
- AddRef
-
- Description:
- Adds to this objects reference count
-
- Parameters:
- returns current reference count
- -------------------------------------------------------------------*/
-
- STDMETHODIMP_(ULONG)
- CSimpleClockSink::AddRef()
- {
- InterlockedIncrement(&m_lRefCount);
-
- return m_lRefCount;
- }
-
- /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- Function:
- Release
-
- Description:
- Decreases reference count, deletes object when necessary ref=0
-
- Parameters:
- returns current reference count
- -------------------------------------------------------------------*/
-
- STDMETHODIMP_(ULONG)
- CSimpleClockSink::Release()
- {
- if(InterlockedDecrement(&m_lRefCount) == 0)
- {
- delete this;
- return(0);
- }
- return m_lRefCount;
- }
-
- /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- Function:
- HandleKeyPress
-
- Description:
- Posts a WM_QUIT. Exits app when any key pressed
-
- Parameters:
- returns S_OK
- -------------------------------------------------------------------*/
-
-
- STDMETHODIMP
- CSimpleClockSink::HandleKeyPress(IDispatch* pdispControl,
- LONG lKeyPress)
- {
-
- PostThreadMessage(m_dwThreadID, WM_QUIT, 0, 0);
- return S_OK;
- }
-
-