|
Window Procedures
The following code has been changed in the "InputWndProc" section.
#define MAX_GUESS 5 // Maximum number of guesses
#define MAX_CHAR 20 // Maximum number of characters per guess
// Global Variables ***************************************************
HRCRESULT vrghresult[MAX_GUESS]; // Array of results
SYV vsyvSymbol[MAX_GUESS][MAX_CHAR]; // Array of symbol strings
int vcSyv[MAX_GUESS]; // Array of string lengths
.
.
.
LRESULT CALLBACK InputWndProc(
HWND hwnd, // Window handle
UINT message, // Message
WPARAM wParam, // Varies
LPARAM lParam ) // Varies
{
LONG lRet = 0L; // Initialize return code to FALSE
HRC hrc; // HRC object
HDC hdc;
PAINTSTRUCT ps;
DWORD dwInfo;
int i, cGuess;
switch (message)
{
.
.
.
case WM_LBUTTONDOWN:
//
// Two possibilities exist: user is using mouse or the pen.
// The latter case indicates the user is starting to write.
//
dwInfo = GetMessageExtraInfo();
if (IsPenEvent( message, dwInfo ))
{
if (DoDefaultPenInput( vhwndInput, (UINT)dwInfo ) == PCMR_OK)
lRet = TRUE;
else
lRet = DefWindowProc( hwnd, message, wParam, lParam );
}
break;
case WM_PENEVENT:
switch (wParam)
{
case PE_GETPCMINFO:
//
// If using SREC recognizer, ensure session ends
// on pen-up.
//
if (viMenuSel == miSample)
((LPPCMINFO) lParam)->dwPcm |= PCM_PENUP;
lRet = DefWindowProc( hwnd, message, wParam, lParam );
break;
case PE_BEGINDATA:
//
// Action based on current menu selection:
//
// 1) If currently using sample recognizer, create an HRC
// for it and specify it in the TARGET structure pointed
// to by lParam. This tells DoDefaultPenInput to use
// the sample recognizer rather than the system default.
//
// 2) If displaying mirror image of ink, create an
// HPENDATA for it and specify it in the TARGET structure
// pointed to by lParam. This tells DoDefaultPenInput to
// collect data into the HPENDATA block instead of
// passing it to a recognizer.
//
// 3) If using the default recognizer, pass to DefWindowProc,
// which sets the maximum number of guesses to 1 and may
// or may not require any guide information. The Japanese
// default recognizer (RODAN.DLL) does require a guide
// for character recognition. The following code shows
// how to access the HRC that DefWindowProc creates,
// reset the number of guesses to MAX_GUESS, and set
// up the client rectangle of the input window as a
// single guide.
//
if (vhpendata)
{
DestroyPenData( vhpendata );
vhpendata = 0;
}
switch (viMenuSel)
{
case miSample:
hrc = CreateCompatibleHRC( NULL, vhrec );
if (hrc)
{
((LPTARGET) lParam)->dwData = hrc;
lRet = LRET_HRC;
}
break;
case miMirror:
vhpendata = CreatePenData( NULL, 0,
PDTS_HIENGLISH, 0 );
if (vhpendata)
{
((LPTARGET) lParam)->dwData = vhpendata;
lRet = LRET_HPENDATA;
}
break;
case miSystem:
lRet = DefWindowProc( hwnd, message,
wParam, lParam );
//
// On return, lParam->dwData points to HRC.
// Use it to reset max number of guesses.
//
SetMaxResultsHRC( ((LPTARGET) lParam)->dwData,
MAX_GUESS );
{
GUIDE guide;
RECT rc;
GetClientRect(vhwndInput, &rc);
ClientToScreen(vhwndInput, (LPPOINT) &rc.left);
ClientToScreen(vhwndInput, (LPPOINT) &rc.right);
guide.xOrigin = rc.left;
guide.yOrigin = rc.top;
guide.cxBox = rc.right - rc.left;
guide.cyBox = rc.bottom - rc.top;
guide.cxBase = 0;
guide.cyBase = guide.cyBox;
guide.cHorzBox = 1;
guide.cVertBox = 1;
guide.cyMid = guide.cyBox / 2;
SetGuideHRC(((LPTARGET) lParam)->dwData, &guide, 0);
}
break;
}
break;
case PE_ENDDATA:
//
// DefWindowProc will destroy vhpendata, so if collecting
// mirror image, don't let DefWindowProc handle message
//
if (viMenuSel != miMirror)
lRet = DefWindowProc( hwnd, message, wParam, lParam );
break;
case PE_RESULT:
//
// At end of input, collect recognition results (if any)
// into symbol strings. DoDefaultPenInput generates the
// PE_RESULT submessage only when using a recognizer.
// The lParam contains the HRC for the recognition process.
//
// NOTE:
// Do not destroy HRC, even after getting results!
// DefWindowProc takes care of destroying the object.
//
// Collect pen data for DrawRawData
- hpendata = CreatePenDataHRC( (HRC) lParam );
// Initialize array to zero
for (i = 0; i < MAX_GUESS; i++)
vcSyv[i] = 0;
// Get number of guesses available
cGuess = GetResultsHRC( (HRC) lParam,
GRH_ALL,
(LPHRCRESULT) vrghresult,
MAX_GUESS );
// Get guesses (in vsyvSymbol) and their lengths (invcSyv)
if (cGuess != HRCR_ERROR)
for (i = 0; i < cGuess; i++)
vcSyv[i] = GetSymbolsHRCRESULT( vrghresult[i],
0,
(LPSYV) vsyvSymbol[i],
MAX_CHAR );
// Destroy the HRCRESULTS
for (i = 0; i < cGuess; i++)
DestroyHRCRESULT(vrghresult[i]);
break;
.
.
.
default:
lRet = DefWindowProc( hwnd, message, wParam, lParam );
} // End switch (message)
return lRet;
}
- In the "DisplayGuesses" section of the "InfoWndProc" section, the following
code has changed.
VOID DisplayGuesses( HDC hdc ) // DC handle
{
TEXTMETRIC tm;
int nX, nY; // Text coords
.
.
.
for (i = 0; i < MAX_GUESS; i++)
{
if (vcSyv[i] > 0)
{
SymbolToCharacter( (LPSYV) vsyvSymbol[i],
vcSyv[i],
(LPSTR) szText,
(LPINT) &cChar );
for (nLen = 0; cChar > 0; cChar--)
nLen += IsDBCSLeadByte(*(szText + nLen)) ? 2 : 1;
TextOut( hdc, nX, nY, (LPSTR) szText, nLen );
nY += tm.tmExternalLeading + tm.tmHeight;
}
}
}
| Last news from Greatis Software |
 |
|
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 |
|
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 |
|
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 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 offers controls with gradient background feature. Labels, panels and so on... Full C# source codes are available More » |
 |
|
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 projectsDmitry Vasiliev (just.dmitry)
Related LinksSoftware 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
|