Using an edit box from other file. Help needed!!
-
I'm trying to make an application that uses a speech recognizer engine but it should write from a .cpp file in the dialogbox defined in other .cpp file and I don't know how could I do. Here is some of my code so you can understand me better: In my main code1.cpp I have defined a edit box with a member variable. In my code it appears on this way:
CIVOCOMDlg::CIVOCOMDlg(CWnd* pParent /*=NULL*/) : CDialog(CIVOCOMDlg::IDD, pParent) { //{{AFX_DATA_INIT(CIVOCOMDlg) m_strHeard = _T(""); //}}AFX_DATA_INIT // Note that LoadIcon does not require a subsequent DestroyIcon in Win32 m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); } void CIVOCOMDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CIVOCOMDlg) DDX_Text(pDX, IDC_GOT, m_strHeard); //}}AFX_DATA_MAP }
Then in this code1.cpp I create a Grammar object:BOOL loadGrammar( TCHAR *pszFile, BOOL bDictGram, ISRGramCommon **ppISRGramCommon ) { ... // load the grammar and register our notify sink IUnknown * pIUnkGram; // create dictation grammar notify sink // CGramDictSink *pGramDictSink = new CGramDictSink( hDlg ); CGramDictSink *pGramDictSink = new CGramDictSink(NULL); pGramDictSink->AddRef(); hRes = g_pISRCentral->GrammarLoad( SRGRMFMT_DICTATION, sData, pGramDictSink, IID_ISRGramNotifySink, &pIUnkGram ); pGramDictSink->Release(); ... hRes = pIUnkGram->QueryInterface( IID_ISRGramCommon,(void **)ppISRGramCommon ); pIUnkGram->Release(); hRes = (*ppISRGramCommon)->Activate( NULL, FALSE, NULL ); return SUCCEEDED( hRes ); }
In the code2.cpp file I have:// notifies client that a recognition has completed STDMETHODIMP CGramCFGSink::PhraseFinish( DWORD dwFlags, QWORD /*qTimeStampBegin*/, QWORD /*qTimeStampEnd*/, PSRPHRASE pSRPhrase, LPUNKNOWN /*lpResults*/ ) { // ignore if not a recognition from this grammar if( !( dwFlags & ISRNOTEFIN_RECOGNIZED ) || !( dwFlags & ISRNOTEFIN_THISGRAMMAR ) ) { return S_OK; } // retrieve the recognized text from SRPHRASE structure PSRWORD pSRMax = (PSRWORD)( (BYTE*)pSRPhrase + pSRPhrase->dwSize ); PSRWORD pSRWord = (PSRWORD)( pSRPhrase->abWords ); TCHAR szText[256] = { _T('\0') }; int nWords = 0; while( pSRWord < pSRMax ) { // add a space between words if( nWords++ != 0 ) _tcscat( szText, _T(" ") ); _tcscat( szText, pSRWord->szWord ); pSRWord = (PSRWORD)( (BYTE *)pSRWord + pSRWord->dwSize ); } SetDlgItemText(m_hDlg, IDC_GOT, "Unrecognized\0"); return S_OK; }
ThisSetDlgItem