#define INITGUID
#include <objbase.h>
#include <objerror.h>
#include <ole2ver.h>
#include "speech.h"
#include <stdio.h>
void abc(char *p)
{ FILE *fp=fopen("z.txt","a+");
fprintf(fp,"%s\n",p);
fclose(fp);
}
MSG c;WNDCLASS a;HWND b;char aa[200];
class ccc : public IVTxtNotifySink
{
public:
STDMETHODIMP QueryInterface (REFIID, LPVOID FAR *);
STDMETHODIMP_(ULONG) AddRef(void);
STDMETHODIMP_(ULONG) Release(void);
STDMETHODIMP AttribChanged (DWORD);
STDMETHODIMP Visual (WCHAR, char, DWORD, PTTSMOUTH);
STDMETHODIMP Speak (PSTR, PSTR, DWORD);
STDMETHODIMP SpeakingStarted (void);
STDMETHODIMP SpeakingDone (void);
};
PIVOICETEXT gpIVTxt;ccc * gpVTxtNotifySink;
LONG CALLBACK zzz( HWND w, UINT x, WPARAM y, LPARAM z)
{
if ( x == WM_LBUTTONDOWN)
{
gpIVTxt->Speak( "hello", 0, NULL );
MessageBox(0,"hi","hi",0);
}
if ( x == WM_DESTROY)
PostQuitMessage(0);
return DefWindowProc(w,x,y,z);
}
int PASCAL WinMain(HANDLE i,HANDLE hPrevInstance,LPSTR lpCmdLine,int nCmdShow)
{
CoInitialize(NULL);
CoCreateInstance(CLSID_VTxt, NULL,CLSCTX_LOCAL_SERVER,
IID_IVoiceText, (void **)&gpIVTxt);
gpVTxtNotifySink = new ccc;
gpIVTxt->Register(NULL,"SRClock",gpVTxtNotifySink,
IID_IVTxtNotifySink, VTXTF_ALLMESSAGES, NULL);
a.lpfnWndProc=zzz;
a.hInstance=i;
a.hbrBackground=GetStockObject(LTGRAY_BRUSH);
a.lpszClassName="ClkClass";RegisterClass(&a);
b=CreateWindow("ClkClass","hi",WS_OVERLAPPEDWINDOW,1,1,100,200,0,0,i,0);
ShowWindow(b,3);
while( GetMessage(&c, 0, 0, 0) )
DispatchMessage(&c);
return 1;
}
STDMETHODIMP ccc::QueryInterface (REFIID riid, LPVOID *ppv)
{
*ppv = NULL;
if (IsEqualIID (riid, IID_IUnknown) || IsEqualIID(riid,IID_IVTxtNotifySink))
{
abc("ccc::QueryInterface 1");
*ppv = (LPVOID) this;
AddRef();
return NOERROR;
}
return E_NOINTERFACE;
}
STDMETHODIMP_ (ULONG) ccc::AddRef (void){ return 0;}
STDMETHODIMP_(ULONG) ccc::Release (void){ return 0;}
STDMETHODIMP ccc::AttribChanged(DWORD dwAttribute){ return NOERROR;}
STDMETHODIMP ccc::SpeakingStarted(void){return 0;}
STDMETHODIMP ccc::SpeakingDone(void){return 0;}
STDMETHODIMP ccc::Visual(WCHAR cIPAPhoneme, char cEnginePhoneme, DWORD dwFlags, PTTSMOUTH pTTSMouth){ return NOERROR;}
STDMETHODIMP ccc::Speak(PSTR pszMessage,PSTR pszApplication,DWORD dwTyep)
{
sprintf(aa,"pszMessage %s pszApplication %s dwTyep %ld",
pszMessage,pszApplication,dwTyep);
abc(aa);
return NOERROR;
}
Move back to the Vijay Mukhi's Technology Cornucopia Page to learn more about the other new Internet Technologies.