MapWinGis.Ocx 4.9.2 crashes on displaying Labels

Oct 20, 2014 at 12:24 PM
Hello everybody,

I'm currently trying to move my Application (Ms-Access 2013, VBA) to MapWinGis 4.9.2.

After installing MapWinGis.ocx everything seems to work, as far as I've tested it. However, when I try to display a layer with labels the application crashes. Everything used to work with MWG 4.8.8...

I use the following code to add Labels
Public Sub insertLabel(objMap As Object, lngColor As Long, strFont As String, _
dblHeight As Double)
    Rem Anzeigen der Labelelemente des Layers
    Rem Param       objMap - Map-Steuerelement
    Rem Param       objColor - Farbe der Label
    Dim dblX As Double
    Dim dblY As Double
    Dim i As Long
    Dim strLabel As String
    ' Shape-Objekt durchlaufen
    For i = 0 To objLayer.NumShapes - 1
        ' Label-Text ermitteln
        strLabel = objLayer.CellValue(intTextField, i)
        ' Label-Koordinaten ermitteln
        dblX = objLayer.Shape(i).Point(0).X
        dblY = objLayer.Shape(i).Point(0).Y
        ' Label anzeigen
        objMap.AddLabel lngLayerHandle, strLabel, lngColor, dblX, dblY, MapWinGIS.tkHJustification.hjCenter
        ' Schriftart und Größe setzen
        objMap.LayerFont lngLayerHandle, strFont, dblHeight
    Next i
End Sub
This part of the code seems to work (but the layer is not displayed on loading) - but when the scale at which the layer should be displayed is reached and the following Sub to display the layer is called, the application crashes in the first line of code (see below)
Public Sub setVisible(objMap As Object, boolVisible As Boolean)
    ' Layer abhängig von boolVisible ein- bzw. ausblenden
    objMap.LayerVisible lngLayerHandle, boolVisible REM - This is where the application crashes
    ' Obektvariable auf den entsprechenden Wert setzen
    boolLayerVisible = boolVisible
End Sub
Can anybody tell me what's wrong or missing? As I said the code used to run with v. 4.8.8.

Thanks and regards


P.S. I did not change the reference to the Map-control
Oct 30, 2014 at 6:21 PM
Have you uninstalled 4.8 completely?
Nov 9, 2014 at 5:09 PM
Hi Ross,

thanks for your reply.

Yes, I did both - uninstall MapWingis.4.8.8 and install MapWinGis.4.9.2 on a newly installed Windows machine without Prior MapWinGis installation. Both to the same result.

Regards Helmut
Nov 23, 2014 at 12:43 PM
Labels have been changed since v4.8.8. Labels are now part of the layer not of the map.

Perhaps you can adjust your code to this example:

Let us know if you keep having trouble.