Home   Index   About
Ultimate Pack


Custom Search
SREC Recognition Functions

This section takes a brief look at some of SREC's exported recognition functions, including CreateCompatibleHRC, ProcessHRC, and CreatePenDataHRC. The code uses the macro

#define lpHRC ((LPHRCinternal) hrc)

to represent a far pointer to the HRC object.

CreateCompatibleHRC

The CreateCompatibleHRC function allocates an HRCinternal structure in the local heap, creates an HPENDATA block for the pen data, and returns a far pointer to the structure. The LPTR argument forces LocalAlloc to return a far pointer to the allocation instead of a memory handle. This far pointer serves as SREC's HRC handle.

Since the HRC has no configurable elements, SREC ignores any template HRC provided in the first parameter.

HRC WINAPI CreateCompatibleHRC( HRC hrcTemplate, HREC hrec )

{

HRC hrc;

hrc = (HRC) LocalAlloc( LPTR, sizeof( HRCinternal ) );

if (hrc)

{

lpHRC->hrec = hrec;

lpHRC->hpendata = CreatePenData( NULL, 0, PDTS_HIENGLISH, 0 );

if (lpHRC->hpendata)

return (hrc);

}

LocalFree( (HLOCAL) hrc ); // If error, free allocation

return NULL; // and return NULL

}

ProcessHRC

The most interesting feature of SREC's ProcessHRC function is the way it sets a time limit for processing. If called with a limit of PH_MIN or PH_DEFAULT, ProcessHRC passes the address of a callback function to SetTimer. When the specified time-out period elapses, the callback function receives control and sets a global flag called vfOutOfTime.

A recognizer can use this technique to ensure that it does not overrun a specified time limit. Its internal processing functions should check the vfOutOfTime flag regularly and, if it is set, terminate immediately. In this case, ProcessHRC returns a value of HRCR_INCOMPLETE to tell the caller recognition has not yet finished.

int WINAPI ProcessHRC( HRC hrc, DWORD dwTimeMax )

{

UINT idTimer, uTime;

int iRet;

  • fOutOfTime = FALSE; // Initialize time-out flag

if (dwTimeMax != PH_MAX) // If time limit specified ...

{

uTime = (dwTimeMax == PH_MIN) ? 50 : 200;

idTimer = SetTimer( NULL, NULL, uTime, (TIMERPROC) TimerProc );

iRet = GetSYG( hrc ); // Quit if out of time

KillTimer( NULL, idTimer );

}

else

iRet = GetSYG( hrc ); // Don't quit until finished

return (iRet);

}

VOID CALLBACK TimerProc( HWND hwnd, UINT ms, UINT iId, DWORD dwTm )

{

  • fOutOfTime = TRUE;

}

CreatePenDataHRC

SREC keeps an HPENDATA handle in its HRC structure. Because the AddPenInputHRC function has already stored pen input in the internal HPENDATA block, CreatePenDataHRC simply duplicates the block.

HPENDATA WINAPI CreatePenDataHRC( HRC hrc )

{

if (hrc)

return (DuplicatePenData( lpHRC->hpendata, 0 ));

else

return NULL;

}


Last news from Greatis Software

Nostalgia .Net     Nostalgia .Net     .Net is powerful, but not all-powerful, so sometimes we need to use Win32 API for our .Net applications. It's simple enough with Platform Invoke if you have Win32 skill, but we do not always have time to dig the ancient documentation, declare the special types that are compatible with Win32, find the values of the Win32's constants and so on. Nostalgia .Net offers several simple-to-use classes, and components that will allow you to forget about the headache of Win32 and just use the power of Win32 in your application the same way as you use the native. Net classes.  More »

Recommended software for developers

Ultimate Pack for Delphi and C++ Builder     Ultimate Pack     Component pack for Delphi and C++ Builder that contains runtime form designer, runtime object inspector, print suite and much more for the very special price.  More »

Form Designer .Net     Form Designer .Net     Unique runtime form design solution that allows to edit any form in .Net WinForms application at runtime with full source codes for only 300 euro!  More »

Print Suite .Net     Print Suite .Net     Print Suite .Net is a set of components for easy printing texts, images and grids from your WinForms applications. Full C# source codes are available  More »

Gradient Controls .Net     Gradient Controls .Net     Gradient Controls .Net offers controls with gradient background feature. Labels, panels and so on... Full C# source codes are available  More »

iGrid     Greatis iGrid     iGrid plots drawing grid right over your desktop, so you can use it everywhere, with any drawing application without any special plugins for different graphic editors.  More »


All the contacts and projects

Dmitry Vasiliev (just.dmitry)

Related Links

Software for Visual Studio .NET developers
Software for Delphi and C++ Builder developers
Software for Visual Basic 6 developers
Delphi Tips&Tricks
MegaDetailed.NET

More Online Helps

Win32 Programmer's Reference
Win32 Multimedia Programmer's Reference
OLE Programmer's Reference
Microsoft Windows Pen API Programmer's Reference
Microsoft Windows Sockets 2 Reference
Microsoft Windows Telephony API (TAPI) Programmer's Reference
Unix Manual Pages

Free Tech Secrets ;) Copyright © 2008-2012 Free Tech Secrets ;) greatis just4fun network just4fun