Work with mapinfo by VB6, help me!!!

Anonymous
03-01-2004, 09:03 PM
I want import a map of mapinfo to VB6, i don't make it, every body help me. func "callback" do not operate in VB6. thank!!!

Eric Frost
03-01-2004, 10:19 PM
Try posting in the MapInfo forum: http://www.mapinfo-l.com

Thanks,
Eric

marmi
02-16-2007, 08:16 AM
hi
this is a way to load a mapinfo table within a vb6 form.
create a vb6 project.

on the form place a picturebox, a commandbutton and a commondialog

// this code goes into module level//
Public itsamap As Boolean
Public mapWinID As Long
Public mapinfo As Object

public Sub OpenATable()
Dim file_name As String
Dim tabName As String
On Error GoTo userCancelled
form1.CommonDialog1.Filter = "MapInfo Tables (*.tab)|*.tab"
form1.CommonDialog1.FilterIndex = 1
form1.CommonDialog1.ShowOpen
file_name = form1.CommonDialog1.FileName
tabName = mapinfo.Eval("PathToTableName$( """ & file_name & """ )")
mapinfo.Do "Open Table """ & file_name & """ as " & tabName
mapinfo.Do "Set Table " & tabName & " ReadOnly"
If mapinfo.Eval("TableInfo(" & tabName & "," & 5 & ")") = "F" Then
MsgBox "Cannot open table!"
mapinfo.Do "Close Table " & tabName
Exit Sub
End If
If itsamap Then
mapinfo.Do "Add Map Layer " & tabName
Else
mapinfo.Do "Set Next Document Parent " & form1.picture1.hWnd & " Style 1"
mapinfo.Do "Map From " & tabName
mapWinID = CLng(mapinfo.Eval("FrontWindow()"))
itsamap = True
End If
Exit Sub
userCancelled:
Exit Sub
End Sub
-----------------------------------------------------------------------
// this code goes into form level//
Private Sub Form_Load()
Set mapinfo = CreateObject("MapInfo.Application")
mapinfo.Do "Set Application Window " & form1.hWnd
End Sub

Private Sub Command1_Click()
Call OpenATable
End Sub

Eric Frost
02-16-2007, 04:54 PM
Cool thanks for posting the code.

That will just post the image, right?

Next time, please surround your code with the code tags, it is the pound symbol. That way it will be properly posted into the forum with indentation. Try it and let me know what you think, you should be able to edit your earlier post.

Eric

marmi
02-20-2007, 06:47 AM
dear eric
actually, the code i submitted for implementing a map within vb does not only display the map as image.
there are some useful constants we can use to execute commands as if we are in mapinfo.
here are some if you want to try.

put the following code in a module:

Global Const M_TOOLS_SELECTOR = 1701
Global Const M_TOOLS_SEARCH_RECT = 1722
Global Const M_TOOLS_SEARCH_RADIUS = 1703
Global Const M_TOOLS_SEARCH_BOUNDARY = 1704
Global Const M_TOOLS_EXPAND = 1705
Global Const M_TOOLS_SHRINK = 1706
Global Const M_TOOLS_RECENTER = 1702
Global Const M_TOOLS_PNT_QUERY = 1707
Global Const M_TOOLS_LABELER = 1708
Global Const M_TOOLS_DRAGWINDOW = 1734
Global Const M_TOOLS_RULER = 1710
Global Const M_TOOLS_INFO = 1790

call them by using the following:
ex:

mapinfo.RunMenuCommand 1708

this will allow you for instance to display the label.

i can e.mail you the entire constants list if you want.

 
Web mp2kmag.com
mapforums.com