To add code to an existing project in order to paint pages and zones:
Start with the program you created in Working with Zones.
Define the following global variables in EZFUNC.H in the OCR_Ltdoc2 directory:
L_BOOL bDrawZones;
L_BOOL bDrawPage;
Define the following global IDs in Ezfunc.h in the OCR_Ltdoc2 directory:
#define IDM_DRAW_ZONES 204
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
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;
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;
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;
Build SimpleLoad.exe.
Run SimpleLoad.exe.