Working with 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. |
Add a command button to your form and name it as follows: |
|
|
Name |
Caption |
|
FINDZONES |
Find Zones |
|
ZONESCOUNT |
Zones Count |
|
VERIFYZONE |
Verify Zone |
3. |
Add the following code to the general declarations section of your project: |
Dim WithEvents ZoneData As LTZoneData
4. |
Add the following code to the main form's Load procedure: |
Set ZoneData = new LTZoneData
5. |
Add the following code to the SHUTDOWN procrdure: |
Set ZoneData = Nothing
6. |
Code the Verification Event procedure as follows: |
Private Sub ZoneData_Verification (ByVal iZoneIndex As Integer, ByVal bstrWord As String)
ZoneData.VerifyCode = VF_ACCEPT
ZoneData.StopVerificationEvent = False
End Sub
7. |
Code the FINDZONES button's click procedure as follows: |
Private Sub FINDZONES_Click()
Dim nRet As Long
LEADRasterDoc.GetAutoZoneOptions
LEADRasterDoc.EnableZoneForceSingleColumn = True
LEADRasterDoc.ShowZoneGridLines = True
LEADRasterDoc.SetAutoZoneOptions
nRet = LEADRasterDoc.FINDZONES(0, True)
If (nRet = 0) Then
MsgBox "Automatic zones method finds all available zones into the specified pages successfully"
Else
MsgBox "Error" + Str(nRet) + "in finding available zone in the specified page"
End If
End Sub
8. |
Code the ZONESCOUNT button's click procedure as follows: |
Private Sub ZONESCOUNT_Click()
Dim nZoneCount As Long
nZoneCount = LEADRasterDoc.ZoneCount (0)
MsgBox "Total Zones count = " + Str(nZoneCount)
End Sub
9. |
Code the VERIFYZONE button's click procedure as follows: |
Private Sub VERIFYZONE_Click()
Dim nZoneCount As Long
Dim nRet As Long
Dim i As Long
nZoneCount = LEADRasterDoc.ZoneCount (0)
For i = 0 To nZoneCount -1
nRet = LEADRasterDoc.GetZoneInfo (0, i, ZoneData)
If (nRet = 0) Then
If ((ZoneData.Flags And ZONE_CHK_CHECKCBF_PROHIBIT) = ZONE_CHK_CHECKCBF_PROHIBIT) Then
ZoneData.Flags = ZoneData.Flags And (Not ZONE_CHK_CHECKCBF_PROHIBIT)
End If
ZoneData.EnableVerificationEvent = True
nRet = LEADRasterDoc.UpdateZone (0, i, ZoneData)
If (nRet <> 0) Then
MsgBox "Error" + Str(nRet) + "in updating zone # " + Str(i)
End If
End If
Next i
End Sub
10. |
Run your program to test it. |
11. |
Save this project to use for testing other code samples. |