Working with Zones (Delphi 6.0)

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.

From the ActiveX tab, Select and Add LTZoneData control to your form.

3.

Add three buttons to your form and name them as follows:

 

Name

Caption

 

btnFindZones

Find Zones

 

btnZonesCount

Zones Count

 

btnVerifyZone

Verify Zone

4.

Handle the LTZoneData OnVerification event, and code the LTZoneData1Verification procedure as follows:

procedure TForm1.LTZoneData1Verification(ASender: TObject; 
  iZoneIndex: Smallint; const bstrWord: WideString); 
begin
 LTZoneData1.VerifyCode:= VF_ACCEPT; 
 LTZoneData1.StopVerificationEvent:= False; 
end;

5.

Code the btnFindZones button's click procedure as follows:

procedure TForm1.btnFindZonesClick(Sender: TObject); 
var
 nRet: Integer; 
begin
   LEADRasterDocument1.GetAutoZoneOptions ( ); 
   LEADRasterDocument1.EnableZoneForceSingleColumn:= True; 
   LEADRasterDocument1.ShowZoneGridLines:= True; 

   LEADRasterDocument1.SetAutoZoneOptions ( ); 
   nRet:= LEADRasterDocument1.FindZones ( 0, True ); 
   if ( nRet = 0 ) then
    ShowMessage ( 'Automatic zones method finds all available zones into the specified pages successfully' ) 
   else
    ShowMessage ( 'Error' + IntToStr(nRet) + 'in finding available zone in the specified page' ); 
end;

6.

Code the btnZonesCount button's click procedure as follows:

procedure TForm1.btnZonesCountClick(Sender: TObject); 
var
 nZoneCount: Integer; 
begin
 nZoneCount:= LEADRasterDocument1.ZoneCount [0]; 
 ShowMessage (  'Total Zones count = ' + IntToStr(nZoneCount) ); 
end;

7.

Code the btnVerifyZone button's click procedure as follows:

procedure TForm1.btnVerifyZoneClick(Sender: TObject); 
var
 i: Integer; 
 nRet: Integer; 
 nZoneCount: Integer; 
begin
 nZoneCount:= LEADRasterDocument1.ZoneCount [0]; 
 for i:= 0 to nZoneCount -1 do
   begin
  nRet:= LEADRasterDocument1.GetZoneInfo ( 0, i, LTZoneData1.DefaultInterface ); 
  if ( nRet = 0 ) then
      begin
     if ((LTZoneData1.Flags And ZONE_CHK_CHECKCBF_PROHIBIT) = ZONE_CHK_CHECKCBF_PROHIBIT) Then
         begin
        LTZoneData1.Flags:= LTZoneData1.Flags And (Not ZONE_CHK_CHECKCBF_PROHIBIT); 
   end; 

     LTZoneData1.EnableVerificationEvent:= True; 
     nRet:= LEADRasterDocument1.UpdateZone ( 0, i, LTZoneData1.DefaultInterface ); 
     if ( nRet <> 0 ) then
      ShowMessage ( 'Error' + IntToStr(nRet) + 'in updating zone # ' + IntToStr(i) ); 
  end; 
 end; 
end;

8.

Run your program to test it.

9.

Save the project to use as a starting point for other tasks in this tutorial.