Painting Pages and Zones Using OCR Plus

To add code to an existing project in order to paint pages and zones:

1.

Start with the program you created in Working with Zones.

2.

Define the following global variables in Ezfunc.h in the OCR_Ltdoc directory:

L_BOOL bDrawZones;
L_BOOL bDrawPage;

 

3.

Define the following global ID in Ezfunc.h in the OCR_Ltdoc directory:

#define IDM_DRAW_ZONES              204
 

4.

Edit EZFUNC.RC file in the OCR_Ltdoc directory and add the following lines:

 

MAIN_MENU   MENU
BEGIN
   ... 
   ... 
   MENUITEM "Enable Draw Zones"     IDM_DRAW_ZONES
END

5.

In Ezfunc.cpp in the MainWndProc procedure, add the following code to the switch statement for WM_COMMAND:

      case IDM_DRAW_ZONES: 
         bDrawZones = !bDrawZones; 
         InvalidateRect (hWnd, NULL, FALSE); 
         break;

 

6.

In EZFUNC.CPP under WM_CREATE inside IDM_INSERT_PAGE, add the following after "L_DocAddPage(…)if (nRet != SUCCESS){…}" :

      
      L_DocSetActivePage(hDoc, 0);
      bDrawPage = TRUE;

      /* Get the client area of the adjusted window */
      GetClientRect(hWnd,&rClientSize);
      /* Make the destination rectangle for painting the same as the client area */
      rLeadDest = rClientSize; 

7.

In the MainWndProc procedure, replace the following code to WM_PAINT (Refer to documentation for an explanation of L_DocDrawPage function):

   case WM_PAINT:
      hdc = BeginPaint (hWnd, &ps); 

      if (bDrawPage)
      {
         if (hpalPaint) /* If we have a paint palette, select it */
         {
            hPalette = SelectPalette (hdc, hpalPaint, TRUE);
            /* Uncomment this if you do not process WM_QUERYNEWPALETTE */
            /* RealizePalette (hdc); */
         }

         L_DocDrawPage(hDoc, hdc, 0, NULL, NULL, &rLeadDest, &ps.rcPaint, SRCCOPY, bDrawZones);
         if (hpalPaint)         /* Return old palette */
            SelectPalette (hdc, hPalette, TRUE);
      }

      EndPaint (hWnd, &ps); /* Return DC */
      return 0;

 

8.

Build SimpleLoad.exe.

9.

Run SimpleLoad.exe.