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 DocumentTutor directory:

L_BOOL bDrawZones;
L_BOOL bDrawPage;

 

3.

Define the following global IDs in Ezfunc.h in the DocumentTutor directory:

#define IDM_DRAW_ZONES              204

 

 

4.

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

 

MAIN_MENU   MENU

BEGIN

   ...

   ...

   MENUITEM "Enable Draw Zones"     IDM_DRAW_ZONES

END

 

5.

In the MainWndProc procedure, add the following code to the switch statement for WM_COMMAND:

      case IDM_DRAW_ZONES:

         bDrawZones = !bDrawZones;

         break;

 

6.

Under WM_CREATE in EZFUNC.CPP, add the following line after "L_DocAddPage()" :

      bDrawPage = FALSE;
      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, add the following code to the WM_PAINT before WM_DESTROY and after WM_SYSCOLORCHANGE:

   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.

For more information, refer to:

OCR Plus Utility demo

Programming with LEADTOOLS OCR

OCR Frequently Asked Questions

Tutorials

Demo Programs