Painting Pages and Zones Using OCR Professional

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

L_BOOL bDrawZones;   
L_BOOL bDrawPage;  

3.

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

#define IDM_DRAW_ZONES              204   
  

4.

Edit EZFUNC.RC file in the OCR_Ltdoc2 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_Doc2AddPage()if (nRet != SUCCESS){}" :

      L_Doc2SetActivePage(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_Doc2DrawPage 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_Doc2DrawPage(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.

Help Version 19.0.2017.10.27
Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.
LEADTOOLS Professional OCR C API Help