add WMS-Layer in vba code

Jun 3 at 4:50 PM
Hello everybody,

I've just started over to update my application (ms access, vba) from MapwinGis 4.8.x to 4.9.4.2.

I guess it'll be quite a challenge.

I wonder if anybody could supply some example code (vba would be fine but not necessary) of how to load a wms Layer?

Thanks in advance and a happy Whit Sunday to all of you
Sep 15 at 1:06 PM
Edited Sep 15 at 1:07 PM
Hi dimpflmoser,

if your still interested:
I do the following:
Create a temporary xml-file describing the wms-layer (Description to be found here: GDAL-WMS)
Then load this file as image and add it to the map.
I've only some VB.NET-code as example:
Dim file As System.IO.StreamWriter
        
        file = My.Computer.FileSystem.OpenTextFileWriter(tempFolder & "\temp_wms.xml", False, System.Text.Encoding.ASCII)

        file.WriteLine("<GDAL_WMS>")
        file.WriteLine("  <Service name=""WMS"">")
        file.WriteLine("    <Version>[WMS-Version]</Version>")
        file.WriteLine("    <ServerUrl>[WMS-URL]</ServerUrl>")
        file.WriteLine("    <SRS>EPSG:25832</SRS>")
        file.WriteLine("    <ImageFormat>image/[WMS-Image-Format]</ImageFormat>")
        file.WriteLine("    <Layers>[WMS-Layer-Name]</Layers>")
        file.WriteLine("  </Service>")
        file.WriteLine("  <DataWindow>")
        file.WriteLine("    <UpperLeftX>[Upper-Left-X-Coordinate]</UpperLeftX>")
        file.WriteLine("    <UpperLeftY>[Upper-Left-YCoordinate]</UpperLeftY>")
        file.WriteLine("    <LowerRightX>[Lower-Right-X-Coordinate]</LowerRightX>")
        file.WriteLine("    <LowerRightY>[Lower-Right-Y-Coordinate]</LowerRightY>")
        file.WriteLine("    <SizeX>[WMS-Width-in-pixel]</SizeX>")
        file.WriteLine("    <SizeY>[WMS-Height-in-pixel]</SizeY>")
        file.WriteLine("  </DataWindow>")
        file.WriteLine("  <AdviseRead>true</AdviseRead>")
        file.WriteLine("  <VerifyAdviseRead>false</VerifyAdviseRead>")
        'file.WriteLine("  <OfflineMode>true</OfflineMode>")
        file.WriteLine("  <Cache>")
        file.WriteLine("  </Cache>")
        file.WriteLine("  <MaxConnections>5</MaxConnections>")
        file.WriteLine("  <Projection>EPSG:25832</Projection>")
        'file.WriteLine("  <OverviewCount>10</OverviewCount>")
        file.WriteLine(" </GDAL_WMS>")

        file.Close()

        Dim im As New MapWinGIS.Image
        im.Open(tempFolder & "\test_wms.xml", MapWinGIS.ImageType.PNG_FILE, False)
        Dim i As Integer = AxMap1.Layers.Add(im, True)
Hope ist helps!

Cheers
Burkhart