Painting Pages and Zones

Take the following steps to add code to the existing project that will let you recognize pages:

1.

Start with the program you created in Working with Pages.

2.

Define the following global variables in EZFUNC.C in the EZOCRDOC directory:

L_BOOL bDrawZones;
L_BOOL bDrawPage;

3.

In Resource View tab, open the EZFUNC resources, and open MAIN_MENU1 menu to add the a new menu item as follows:

 

a.

Select an empty rectangle in the menu, and right click on that box and select Properties.

 

b.

Set the ID to IDM_DRAW_ZONES and the Caption to Enable Draw Zones. Make sure Checked has been selected. Press Enter.

4.

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

         bDrawZones = !bDrawZones;
         break;

5.

Under WM_CREATE in EZFUNC.C, 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;

6.

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;

7.

Build Ezfunc32.exe.

8.

Run Ezfunc32.exe.