Hello everybody,
in my Project (win 8.1 64, MS-Access 2013 - 32, vba, MapWindow.ocx 4.9.3.5 Win32) I use the following code to find a shape and change the fillColor of it:
Can anybody see whats wrong?
Thanks and regards
in my Project (win 8.1 64, MS-Access 2013 - 32, vba, MapWindow.ocx 4.9.3.5 Win32) I use the following code to find a shape and change the fillColor of it:
REM ...
' Layerobjekt erstellen
Set objShape = Forms(strMap).mapMain.GetObject(lngHandle)
' Index erstellen
intIndexField = objShape.Table.FieldIndexByName("oid")
objShape.Categories.Generate intIndexField, MapWinGIS.tkClassificationType.ctUniqueValues, 0
objShape.Categories.ApplyExpressions
' Shape-Objekte durchlaufen
For i = 0 To objShape.NumShapes - 1
' auf GemarkungsNr testen
If objShape.CellValue(1, i) = CStr(gmkgNr) Then
' Testen, ob FlurstücksNr übereinstimmt
If objShape.CellValue(2, i) = CStr(flstNr) Then
' Testen, ob Teilfläche übereinstimmt
If objShape.CellValue(3, i) = CStr(flstTl) Then
' Auf Shape zoomen
Forms(strMap).mapMain.ZoomToShape lngHandle, i
' Fenster vergößern - in Prozent
Forms(strMap).mapMain.zoomOut (3)
' Farbe setzen
lngShpIndex = objShape.ShapeCategory(i) ' lngShpIndex = -1
' Testen, ob Füllfarbe übergeben
If IsMissing(fillColor) Then
'objShape.Categories.Item(lngShpIndex).DrawingOptions.fillColor = ReadIni.getWert("SelectionColor")
objShape.Categories.Item(lngShpIndex).DrawingOptions.fillColor = 10584682
Else
objShape.Categories.Item(lngShpIndex).DrawingOptions.fillColor = fillColor
End If
' Karte neu zeichnen - sonst wird beim ersten Aufruf das Flurstück nicht markiert
Forms(strMap).mapMain.Redraw
End If
End If
End If
Next i
REM ...
The shape is found, as the inner if branch is entered, but lngShpIndex is set to -1 and accordingly the line:objShape.Categories.Item(lngShpIndex).DrawingOptions.fillColor = 10584682
produces an "Object or withblock not set" error.Can anybody see whats wrong?
Thanks and regards