Painting Pages and Zones Using LEADTOOLS OCR Module - OmniPage Engine

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 20.0.2020.4.2
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2020 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS OCR Module - OmniPage Engine C API Help