Visual studio 2005 thinks that long long int is 64 bit. The difference between
[dasher.git] / Src / Win32 / ActionSpeech.cpp
bloba0c5ef45553b87f974663b631aa70a6132a805c3
1 #include "ActionSpeech.h"
3 CActionSpeech::CActionSpeech() {
4 m_bActive = false;
7 // TODO: The next few methods are pretty much boiler plate - move into parent?
8 std::string CActionSpeech::GetName() {
9 return "Speak";
12 bool CActionSpeech::Activate() {
13 HRESULT hr = CoCreateInstance(CLSID_SpVoice, NULL, CLSCTX_ALL, IID_ISpVoice, (void **)&pVoice);
15 if(hr!=S_OK)
16 pVoice=0;
18 if(pVoice == 0) {
19 m_bActive = false;
20 return false;
23 // TODO: Why is this needed?
24 pVoice->Speak(L"",SPF_ASYNC,NULL);
26 m_bActive = true;
27 return true;
30 bool CActionSpeech::Deactivate() {
31 if (pVoice!=NULL) {
32 pVoice->Release();
33 pVoice=NULL;
36 m_bActive = false;
37 return true;
40 bool CActionSpeech::GetActive() {
41 return m_bActive;
44 bool CActionSpeech::Execute(const std::wstring &strText) {
45 if(!m_bActive)
46 return false;
48 if(pVoice == 0)
49 return false;
51 pVoice->Speak(strText.c_str(), SPF_ASYNC, NULL);
53 return true;
56 void CActionSpeech::Preview(const std::wstring &strText) {
57 Execute(strText);