漫談WinCE的手寫識別技術(shù)(二)
HWXSETCONTEXT = (DLL_HWXSETCONTEXT) GetProcAddress(hInstDll,TEXT(HwxSetContext));
HWXINPUT = (DLL_HWXINPUT) GetProcAddress(hInstDll,TEXT(HwxInput));
HWXPROCESS = (DLL_HWXPROCESS) GetProcAddress(hInstDll,TEXT(HwxProcess));
HWXRESULTSAVAILABLE = (DLL_HWXRESULTSAVAILABLE) GetProcAddress(hInstDll,TEXT(HwxResultsAvailable));
HWXGETRESULTS = (DLL_HWXGETRESULTS) GetProcAddress(hInstDll,TEXT(HwxGetResults));
HWXDESTROY = (DLL_HWXDESTROY) GetProcAddress(hInstDll,TEXT(HwxDestroy));
HWXENDINPUT = (DLL_HWXENDINPUT) GetProcAddress(hInstDll,TEXT(HwxEndInput));
}
else
{
return FALSE;
}
#endif //RECOGNIZE_FUNCTION_FROM_DLL
if(HWXCONFIG() == FALSE)
{
return FALSE;
}
return TRUE;
}
//-----------------------------------------------------------------------
//Descriptiong:
// Begin recognizing
//-----------------------------------------------------------------------
BOOL CRecognizer::BeginRecognize()
{
BOOL bRes = FALSE;
m_hrc = HWXCREATE();
if(m_hrc == NULL)
{
goto END;
}
bRes = HWXSETGUIDE(m_hrc,m_hwxGuide);
if(bRes == FALSE)
{
goto END;
}
bRes = HWXALCVALID(m_hrc,m_alc);
if(bRes == FALSE)
{
goto END;
}
bRes = TRUE;
END:
return bRes;
}
//-----------------------------------------------------------------------
//Descriptiong:
// End recognizing
BOOL CRecognizer::EndRecognize()
{
BOOL bRes = FALSE;
//Destroy the recognizer
if(HWXDESTROY(m_hrc) == FALSE)
{
goto END;
}
bRes = TRUE;
END:
return bRes;
}
//Descriptiong:
// Get the character
//Parameters:
// pWchar: [out] The character get to be stored
// iCount: [in] The number of pWchar
//Return Values:
// 0: Failed
// >0: The number of the characters to return
int CRecognizer::GetCharacter(WCHAR *pWchar, int iCount)
{
int iGetNum = 0;
int i = 0;
HWXRESULTS *phwxResults;
//Because each HWXRESULTS after the first one could store two characters,
//so only allocate (iCount / 2 + 1)
int iNum = iCount / 2 + 1;
phwxResults = new HWXRESULTS[iNum];
memset(phwxResults,0,iNum * sizeof(HWXRESULTS));
//End the input
if(HWXENDINPUT(m_hrc) == FALSE)
{
goto END;
}
//Analyze the information
if(HWXPROCESS(m_hrc) == FALSE)
評論