Working with Zones Tutorial
To add code to an existing project that will let you recognize pages:
1. |
Start with the program you created in Working with Pages. |
2. |
Define the following global IDs in Ezfunc.h in the DocumentTutor directory: |
#define IDM_FIND_ZONES 201
#define IDM_ZONES_COUNT 202
#define IDM_ADD_VERIFICATION_ZONE 203
3. |
Edit EZFUNC.RC file in the DocumentTutor directory and add the following lines: |
MAIN_MENU MENU
BEGIN
...
...
MENUITEM "Find Zones" IDM_FIND_ZONES
MENUITEM "Zone Count" IDM_ZONES_COUNT
MENUITEM "Add Verification Zone" IDM_ADD_VERIFICATION_ZONE
END
4. |
Define the following global variables in Ezfunc.H in the DocumentTutor directory: |
L_INT nZoneCount;
5. |
In the MainWndProc procedure, add the following code to the switch statement for WM_COMMAND: |
case IDM_FIND_ZONES:
{
AUTOZONEOPTS ZoneOpts;
memset(&ZoneOpts, 0, sizeof(AUTOZONEOPTS));
ZoneOpts.uStructSize = sizeof(AUTOZONEOPTS);
ZoneOpts.bEnableForceSingleColumn = TRUE;
ZoneOpts.bVisibleGridLines = TRUE;
L_DocSetZoneOptions(hDoc, &ZoneOpts);
nRet = L_DocFindZones(hDoc, 0, NULL);
if (nRet == SUCCESS)
MessageBox(NULL, TEXT("The automatic zone method found all available zones in the specified pages successfully."), TEXT("Notice!"), MB_OK);
else
{
wsprintf (achBuff, TEXT("Error %d in finding available zones in the specified page."), nRet);
MessageBox (NULL, achBuff, TEXT("Error"), MB_OK);
}
}
break;
case IDM_ZONES_COUNT:
{
nRet = L_DocGetZoneCount(hDoc, 0, &nZoneCount);
if (nRet == SUCCESS)
{
wsprintf(achBuff, TEXT("Total Zones count = %d\n"), nZoneCount);
MessageBox(NULL, achBuff, TEXT("Zones Count"), MB_OK);
}
}
break;
case IDM_ADD_VERIFICATION_ZONE:
{
ZONEDATA Zone;
L_INT i;
for(i=0; i<nZoneCount; i++)
{
memset(&Zone, 0, sizeof(ZONEDATA));
nRet = L_DocGetZone(hDoc, 0, i, &Zone, sizeof(ZONEDATA));
if (nRet == SUCCESS)
{
if ((Zone.uFlags & ZONE_CHK_CHECKCBF_PROHIBIT) == ZONE_CHK_CHECKCBF_PROHIBIT)
Zone.uFlags &= ~ZONE_CHK_CHECKCBF_PROHIBIT;
Zone.pfnCallback = VerificationCB;
nRet = L_DocUpdateZone(hDoc, 0, i, &Zone);
if (nRet != SUCCESS)
{
wsprintf (achBuff, TEXT("Error %d in updating zone # %d"), nRet, i);
MessageBox (NULL, achBuff, TEXT("Error"), MB_OK);
}
}
}
}
break;
6. |
Add the following function in EZFUNC.CPP in the DocumentTutor directory. |
L_INT EXT_CALLBACK VerificationCB(L_INT nZoneIndex, L_TCHAR * pszWord, VERIFYCODE * pVerify, L_VOID * pUserData)
{
UNREFERENCED_PARAMETER(nZoneIndex);
UNREFERENCED_PARAMETER(pszWord);
UNREFERENCED_PARAMETER(pUserData);
*pVerify = VERIFY_ACCEPT;
return SUCCESS;
}
7. |
Also, add the following statement before the MainWndProc function. |
L_INT EXT_CALLBACK VerificationCB(L_INT nZoneIndex, L_TCHAR * pszWord, VERIFYCODE * pVerify, L_VOID * pUserData);
8. |
Build SimpleLoad.exe. |
9. |
Run SimpleLoad.exe. |