Starting MapInfo from VB.Net

1,006 views
Skip to first unread message

Andy Foy

unread,
Aug 12, 2013, 12:06:18 PM8/12/13
to mapi...@googlegroups.com
Hi
 
I've inherited a VB.NET application that starts MapInfo and then communicates with it to perform mapping actions controlled by the application user interface. It currently uses v1.0.2 of the MapinfoDotNetWrapper.dll.  If the application is installed on a system with MI 8.0 then it starts MI fine.  But if it is installed on a system with MI 10.5 or above (it may be 10.0 or above) it starts MI but does not have some of the MI 10.5 features (and hence still looks and performs like MI 8.0).  For example the layer control window is not dockable!
 
I've tried starting MI using the MapInfo 10.5 OLE Automation Type Library with the following code ...
 
Imports MapInfo
Public Class Form1
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Dim miobj As New MapInfo.MapInfoApplication
        miobj.Visible = True
    End Sub
End Class
 
It starts MI in the same way as the MapinfoDotNetWrapper.dll (i.e. without a dockable layer control).  How do I start MI 10.5 from VB.Net so that it starts MI as if I had started it from windows?
 
Can anyone help me?  I'm new to VB.Net so I might be making a really obvious error.
 
Many thanks
Andy
 

Peter Horsbøll Møller

unread,
Aug 12, 2013, 2:06:12 PM8/12/13
to mapi...@googlegroups.com
Andy

The later versions of MI Pro, v10-12, still have the old layer control that can't be docked.
Normally you just never see this is it's the dockable layer control that is used by default.

If you however create your own application you can show the old layer control in stead of the new.

So the question now is how does you application show the layer control?

Peter Horsbøll Møller
Pitney Bowes Software



Date: Mon, 12 Aug 2013 09:06:18 -0700
From: an...@andyfoyconsulting.co.uk
To: mapi...@googlegroups.com
Subject: [MI-L] Starting MapInfo from VB.Net
--
--
You received this message because you are subscribed to the
Google Groups "MapInfo-L" group.To post a message to this group, send
email to mapi...@googlegroups.com
To unsubscribe from this group, go to:
http://groups.google.com/group/mapinfo-l/subscribe?hl=en
For more options, information and links to MapInfo resources (searching
archives, feature requests, to visit our Wiki, visit the Welcome page at
http://groups.google.com/group/mapinfo-l?hl=en
 
---
You received this message because you are subscribed to the Google Groups "MapInfo-L" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mapinfo-l+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Andy Foy

unread,
Aug 13, 2013, 5:43:41 AM8/13/13
to mapi...@googlegroups.com
Hi Peter
 
My application is not doing anything with the layer control itself - it just acts as an interface to display/update data related to a MI table from a relational database.  It starts a new instance of MapInfo, opens an existing workspace and then communicates with that instance of MI to retrieve the keys of the selected feature(s) in the relevant MI table (so it can display the related data from the database) or it selects feature(s) in the MI table if the user queries them in the application interface.  All the MI interaction (apart from querying selecting features from a given MI table) are left to the user in native MI.
 
So what I don't understand is, how come I can create (open) an instance of MI and open an existing workspace but MI doesn't open the same way as it would if I opened MI and the workspace from windows?  Is there any way I can open MI from a .Net application as if it has been opened normally by windows (so that all the user's toolbar settings and positions are left as they were and the layer control is dockable)?
 
Thanks
Andy

Andy Foy

unread,
Sep 17, 2013, 9:46:45 AM9/17/13
to mapi...@googlegroups.com
Hi Peter
 
I've just got round to looking at this again and now have access to a MapInfo v12 but still have the same problem. It seems that if I reference the MapInfo 12.0 OLE Automation Type library in a .NET application and start MapInfo using the following VB code:
 
Dim miobj As New MapInfo.MapInfoApplication
miobj.Visible = True
 
Then MapInfo is started with the /Automation parameter because this is what appears in the registry under the CLSID for "MapInfo.Application". In this case MapInfo doesn't have a dockable layer control (and otherwise has the look and feel of MI v8).  The same happens if I don't reference the COM object and start MapInfo using the following C# code (sorry for the mix of languages):
 
Type mapinfotype = Type.GetTypeFromProgID("Mapinfo.Application");
object instance = Activator.CreateInstance(mapinfotype);
 
According to an old post I found on the forum the /Automation parameter does the following:
 
MapInfo registers its OLE Class Factory with the OLE subsystem, which allows MapInfo to act as a behind-the-scenes OLE server to another application
 
Is it possible to start MapInfo so that I can still interact with it from a .NET application but so that it still appears "normal" to the user (e.g. has a dockable layer control)?
 
Many thanks
Andy
 

Glen O

unread,
Sep 17, 2013, 10:35:52 AM9/17/13
to mapi...@googlegroups.com
I use this to start MapInfo in 1 monitor and a VB.net interface in a 2nd monitor
 
like a VB.Net remote control
 
 
 
Imports System.Runtime.InteropServices
Imports MapInfo
Imports System.IO
Public Class Form1
    Public mapinfo As MapInfo.MapInfoApplication
   

    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
       
        mapinfo = New MapInfo.MapInfoApplication
        mapinfo.Visible = True
        mapinfo.Do("Set Window 1011 Max")
        mapinfo.Do("Alter ButtonPad ""Tools"" Show Fixed")
        mapinfo.Do("Alter ButtonPad ""Main"" Show Fixed")
        mapinfo.Do("Alter ButtonPad ""Standard"" Show Fixed")
        mapinfo.Do("Alter ButtonPad ""Web Services"" Show Fixed")
        mapinfo.Do("Alter ButtonPad ""Drawing"" Show Fixed")
      
    End Sub
 
    Private Sub ExitToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles ExitToolStripMenuItem.Click
        mapinfo.Do("End Mapinfo Interactive")
    End Sub
 
    Private Sub Form_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        mapinfo.Do("End Mapinfo Interactive")
    End Sub
 
    Private Sub ShowMapinfoToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles ShowMapinfoToolStripMenuItem.Click
        mapinfo.Visible = True
    End Sub
End Class

Andy Foy

unread,
Sep 18, 2013, 4:11:21 AM9/18/13
to mapi...@googlegroups.com
Thanks Glen
 
What version of MI are you using?  When I execute this it still starts MI in it's 'old style' without a dockable layer control.
 
Andy

Glen O

unread,
Sep 18, 2013, 12:30:49 PM9/18/13
to mapi...@googlegroups.com
MapInfo 10 you should just be able to turn it on
or open it and dock it
 
I will look at that and see if I can figure out the command  

Glen O

unread,
Sep 18, 2013, 2:12:15 PM9/18/13
to mapi...@googlegroups.com

I can dock and un dock
 
how are you opening the layer control?
 
I can not get 'mapinfo.Do("Run Menu Command""M_TOOLS_SEARCH_RADIUS") to work no error just does not open

Andy Foy

unread,
Sep 18, 2013, 4:22:55 PM9/18/13
to mapi...@googlegroups.com
I'm using either the menu bar ... Map --> Layer Control, or I'm using <ctrl>L.
 
Are you starting MI using the VB.Net code you posted earlier when you try and dock and undock the layer control?  If I start MI from windows I can dock/undock fine, it's only when I start MI from a .NET application that the layer control is undockable.
 

Glen O

unread,
Sep 18, 2013, 8:40:14 PM9/18/13
to mapi...@googlegroups.com

using the code I posted I can open the layer control and it starts docked and I can undock it
 
how many versions of mapinfo are on your machine? 

Andy Foy

unread,
Sep 19, 2013, 6:32:00 AM9/19/13
to mapi...@googlegroups.com
Strange ... I've got 2 PCs, one with only MI 11.5 and one with only MI 12.0.  I have the same problem on both of them when running your code from Visual Studio 2012 using .NET 4.5 to start MI.
 
Any ideas?
 

Glen O

unread,
Sep 19, 2013, 11:33:09 AM9/19/13
to mapi...@googlegroups.com
I can send you the VB.net 2010 project
 
project settings /application
 
enable Application frame work
 
reference
 
MapInfo 10.0 OLE automation type lib
 
net framework 4.0
 
but no idea why that would be
 
 
Reply all
Reply to author
Forward
Message has been deleted
0 new messages