home *** CD-ROM | disk | FTP | other *** search
- //--------------------------------------------------------------------------------------------
- //
- // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
- // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
- // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
- // PARTICULAR PURPOSE.
- //
- // Copyright (c) Microsoft Corporation, 1997 All Rights Reserved
- //
- // Description:
- //
- // Contains the base application level code and classes for a simple Apollo application
- //
- //--------------------------------------------------------------------------------------------
-
- #include <windows.h>
- #include <olectl.h>
- #include <asfc.h>
- #include <ascmnctl.h>
- #include <speech.h>
-
- #include "app.h"
- #include "resource.h"
- #include "appsink.h"
-
-
- //global app object
- extern CTTSApp * g_pApp;
- //--------------------------------------------------------------------------------------------
- //
- // CFormEventSink Class implementation
- //
- //--------------------------------------------------------------------------------------------
-
- //+-------------------------------------------------------------------------
- //
- // Function: CFormEventSink::CFormEventSink
- //
- // Synopsis: Constructor, just initializes reference count.
- //
- // Arguments: none
- //
- // Returns: void
- //
- //---------------------------------------------------------------------------
-
- CFormEventSink::CFormEventSink()
- {
- m_cRef = 0;
- }
-
- //+-------------------------------------------------------------------------
- //
- // Function: CFormEventSink::QueryInterface
- //
- // Synopsis: Standard IUnknown method. Returns requested interface.
- //
- // Arguments: REFIID - reference to Interface GUID
- // PVOID - returned interface pointer
- //
- // Returns: HRESULT result code
- //
- //---------------------------------------------------------------------------
-
- STDMETHODIMP
- CFormEventSink::QueryInterface( REFIID riid,
- PVOID *ppv)
- {
-
- HRESULT hr = NOERROR;
-
- if (!ppv)
- hr = E_INVALIDARG;
-
- // Returns requested interface, if it is supported
- if( SUCCEEDED( hr ) ) {
- if (riid == IID_ASEVENTSINK)
- *ppv = (PVOID) (IASEventSink*) this;
- else if (riid == IID_IUnknown)
- *ppv = (PVOID) (IUnknown*) (IVCmdNotifySinkW*) this;
- else if (riid == IID_IDispatch)
- *ppv = (PVOID) (IDispatch*) this;
- else
- hr = E_NOINTERFACE;
- }
-
- if( SUCCEEDED( hr ) )
- AddRef();
-
- return hr;
- }
-
- //+-------------------------------------------------------------------------
- //
- // Function: CFormEventSink::AddRef
- //
- // Synopsis: Increments objects reference count.
- //
- // Arguments: none
- //
- // Returns: ULONG - Current reference count
- //
- //---------------------------------------------------------------------------
- STDMETHODIMP_(ULONG)
- CFormEventSink::AddRef()
- {
- InterlockedIncrement(&m_cRef);
-
- return m_cRef;
- }
-
- //+-------------------------------------------------------------------------
- //
- // Function: CFormEventSink::Release
- //
- // Synopsis: Decrements reference count, deletes object if it == 0.
- //
- // Arguments: none
- //
- // Returns: ULONG - Current reference count
- //
- //---------------------------------------------------------------------------
- STDMETHODIMP_(ULONG)
- CFormEventSink::Release()
- {
-
- if (InterlockedDecrement(&m_cRef) == 0)
- {
- delete this;
- return(0);
- }
- return m_cRef;
- }
-
- //+-------------------------------------------------------------------------
- //
- // Function: CFormEventSink::ReceiveMsg
- //
- // Synopsis: Event sink to be attatched to form. Calls main app's ProcessMessage
- // function to handle messages it receives.
- //
- // Arguments: LONG uMsg - Win 32 message
- // LONG wParam - message parameter
- // LONG lParam - message parameter
- //
- // Returns: void
- //
- //---------------------------------------------------------------------------
-
- STDMETHODIMP
- CFormEventSink::ReceiveMsg(LONG uMsg, LONG wParam, LONG lParam)
- {
-
- g_pApp->ProcessMessage(uMsg, wParam, lParam);
- return S_FALSE;
- }
-
- //--------------------------------------------------------------------------------------------
- //
- // CAppMessageSink class implementation
- //
- //--------------------------------------------------------------------------------------------
-
- //+-------------------------------------------------------------------------
- //
- // Function: CAppMessageSink::CAppMessageSink
- //
- // Synopsis: Constructor, just initializes reference count.
- //
- // Arguments: none
- //
- // Returns: void
- //
- //---------------------------------------------------------------------------
-
- CAppMessageSink::CAppMessageSink()
- {
- m_cRef = 0;
- }
-
- //+-------------------------------------------------------------------------
- //
- // Function: CAppMessageSink::QueryInterface
- //
- // Synopsis: Returns pointer to requested interface.
- //
- // Arguments: REFIID - Requested interface's GUID
- // PVOID - pointer to interface return
- //
- // Returns: HRESULT result code
- //
- //---------------------------------------------------------------------------
- STDMETHODIMP
- CAppMessageSink::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: CAppMessageSink::AddRef
- //
- // Synopsis: Increments objects reference count.
- //
- // Arguments: none
- //
- // Returns: ULONG - Current reference count
- //
- //---------------------------------------------------------------------------
-
- STDMETHODIMP_(ULONG)
- CAppMessageSink::AddRef()
- {
- InterlockedIncrement(&m_cRef);
- return m_cRef;
- }
-
- //+-------------------------------------------------------------------------
- //
- // Function: CAppMessageSink::Release
- //
- // Synopsis: Decrements reference count, deletes object if it == 0.
- //
- // Arguments: none
- //
- // Returns: ULONG - Current reference count
- //
- //---------------------------------------------------------------------------
- STDMETHODIMP_(ULONG)
- CAppMessageSink::Release()
- {
- if (InterlockedDecrement(&m_cRef) == 0)
- {
- delete this;
- return(0);
- }
- return m_cRef;
- }
-
- //+-------------------------------------------------------------------------
- //
- // Function: CAppMessageSink::HandleMessage
- //
- // Synopsis: Message sink attatched to the Forms manager. Handles the
- // WM_SPCH_NOTIFY messages and detects when someone changes the
- // feedback level outside our application.
- //
- // Arguments: IDispatch* - Pointer to control calling this method
- // LONG uMsg - Win32 Message
- // LONG wParam - Message parameter
- // LONG lParam - Message parameter
- //
- // Returns: S_FALSE - keeps messages going down the pipeline
- //
- //---------------------------------------------------------------------------
- STDMETHODIMP
- CAppMessageSink::HandleMessage(IDispatch* pdispControl, LONG uMsg, LONG wParam, LONG lParam)
- {
- switch(uMsg)
- {
- default:
- break;
-
- case WM_SPCH_NOTIFY: // Notifications from TTS engine
- switch(wParam)
- {
- default:
- break;
-
- case VTXTF_SPEAKDONE: // When a TTS phrase is done, this is called
- g_pApp->OnSpeakDone(); // Call a CTTSApp function to handle this
- break;
-
- case VTXTF_SPEAK: // Messages fired while TTS engine is speaking, holds
- // the bookmark ID passed to the Speak function
- g_pApp->SetFocusOnId(lParam); // in this App, the bookmark ID is the
- break; // ID of the menu item about to be said
- } //end switch(wParam)
- break;
-
- case WM_SETTINGCHANGE: // Fired when a system setting changed
- if(wParam == SPI_SETAPCFEEDBACK) g_pApp->GetFeedbackLevels(); // Feedback level changed
- break; // Refresh our applications variables
-
- } //end switch(uMsg)
-
- return S_FALSE; // return S_FALSE to keep message going on its way down the hiarchy
- }
-
- //+-------------------------------------------------------------------------
- //
- // Function: CAppMessageSink::ReceiveMsg
- //
- // Synopsis: Event sink attatched to the Forms manager. We don'e handle any
- // of the events in this function right now.
- //
- // Arguments: LONG uMsg - Win32 Message
- // LONG wParam - Message parameter
- // LONG lParam - Message parameter
- //
- // Returns: S_FALSE - keeps messages going down the pipe.
- //
- //---------------------------------------------------------------------------
- STDMETHODIMP CAppMessageSink::ReceiveMsg(long uMsg, long wParam, long lParam)
- {
- return S_FALSE;
- }
-
-
-
-