Working with Zones

Take the following steps to add code to the existing project that will let you recognize pages:

1.

Start with the program you created in Working with Pages.

2.

In Resource View tab, open the EZFUNC resources, and open MAIN_MENU1 menu to add the a new menu item as follows:

 

a.

Select an empty rectangle in the menu, and right click on that box and select Properties.

 

b.

Set the ID to IDM_FIND_ZONES and the Caption to Find Zones. Make sure Checked has been selected. Press Enter.

 

c.

Select another empty rectangle appears on the menu. Right click on that box and select Properties.

 

d.

Set the ID to IDM_ZONES_COUNT and the Caption to Zone Count. Make sure Checked has been selected. Press Enter.

 

e.

Select another empty rectangle appears on the menu. Right click on that box and select Properties.

 

f.

Set the ID to IDM_ADD_VERIFICATION_ZONE and the Caption to Add Verification Zone. Make sure Checked has been selected. Press Enter.

3.

Define the following global variables in EZFUNC.C in the EZOCRDOC directory:

L_INT nZoneCount;

4.

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;

 

5.

Add the following function in EZFUNC.C in the EZOCRDOC directory.

L_INT EXT_CALLBACK VerificationCB(L_INT nZoneIndex, L_TCHAR L_FAR * pszWord, VERIFYCODE * pVerify, L_VOID L_FAR * pUserData)
{
  *pVerify = VERIFY_ACCEPT;
   return SUCCESS;
}

6.

Also, add the following statement before the MainWndProc function.

L_INT EXT_CALLBACK VerificationCB(L_INT nZoneIndex, L_TCHAR L_FAR * pszWord, VERIFYCODE * pVerify, L_VOID L_FAR * pUserData);

7.

Build Ezfunc32.exe.

8.

Run Ezfunc32.exe.