Terry The MapInfo OLE object model is so small and old that the VB examples in the manual probably tell you all you need to know.
To keep control of what you are doing I'd suggest sticking to invoking the MapBasic commands within your code rather than putting them in an MBX - you will lose execution speed but unless you are iterating through hundreds of rows the benefit of stepping your code probably outweighs this. Use of MapBasic scripts - by which I assume you mean MBXs - just gives you more threads to compile and debug and MapBasic is a b----r for that. (You could use DDE communication to an MBX and this does work - ie send your errors back down the DDE channel but debugging is still tougher than in-line within your development environment) I've built an object model in VB around MI and a few other people have done the same - to make it easier to use and more like MapX - but ultimately its just a wrapper for sending in MapBasic strings. But a good step would be to put the .do,.eval, .runmenucommand etc statements into a class and wrap each one with an error handler. Don't know why your form loads and runs then vanishes but I'm willing to bet that it loads then the form itself has nothing to do and unloads - try reparenting to a picture box. ALSO - make sure you destroy your object referenec to MapInfo on exiting, or you can clutter up your task manager with dead mapinfow.exe sessions. .NET should be a lot easier!!! Paul Crisp Syntegra Innovation Place Delta Bank Road Newcastle NE11 9DJ Tel 0191 461 4522 Fax 0191 460 1987 -----Original Message----- From: Terry McDonnell [mailto:[EMAIL PROTECTED] Sent: 27 January 2004 11:45 To: [EMAIL PROTECTED] Subject: MI-L Driving MapInfo, via MapBasic, from Visual Foxpro Hello, All, I can't get info anywhere on how to drive MapBasic applets from VFP. I'm a total newbie to GIS but very experienced in VFP I have MapInfo maps and I need to plot VFP-held routes along roads on the maps So I need to either invoke loads of MapBasic commands, through integrated mapping, from VFP (and there's NO documentation on how to do that - the nearest thing being VB examples), or construct small MapBasic applets and invoke them from VFP. (and there's NO documentation on how to do that) I'm leaning toward the latter but my attempts have failed to do anything other than bring up a useless VFP window, whatever MapInfo stuff going on flashes up and then disappears as soon as the MapBasic .MBX is finished. i.e. I see my map then it's gone. Below is my VFP code (and I only got this far from the ONE example I could find at MapInfo's website): _________________________________ lcHWND = TRANSFORM( thisForm.hWnd ) loMapInfo = CreateObject("MapInfo.application") lcHWND = transform( thisForm.hWnd ) loMapInfo.do( "Set Application Window " + lcHWND ) loMapInfo.do( "Set Next Document Parent " + lcHWND + " Style 1" ) lcProg = 'Run Application "C:\mcl_windows\Testbed\MapBas\junk2.MBX"' loMapInfo.Do ( LcProg) _________________________________ The MapBasic JUNK2.MB (just a familiarisation exercise) looks like: _________________________________ Dim I as Integer Include "MAPBASIC.DEF" Open Table "C:\mcl_windows\Testbed\MapInfoMaps\UK_NUTS2.TAB" Interactive Map From UK_NUTS2 Position (3,2) units "in" Height 6 Units "in" Width 8 Units "in" Open Table "C:\mcl_windows\Testbed\MapInfoMaps\UK_REGNS.TAB" Interactive Add Map Auto Layer UK_REGNS set map redraw on Open Table "C:\mcl_windows\Testbed\MapInfoMaps\UK_A_RDS.TAB" Interactive Add Map Auto Layer UK_A_RDS Open Table "C:\mcl_windows\Testbed\MapInfoMaps\UKCTY203.TAB" Interactive Add Map Auto Layer UKCTY203 Open Table "C:\mcl_windows\Testbed\MapInfoMaps\UKMTRWAY.TAB" Interactive Add Map Auto Layer UKMTRWAY Open Table "C:\mcl_windows\Testbed\MapInfoMaps\suffolk\Streets.TAB" Interactive Add Map Auto Layer Streets Set Map Layer 0 Editable On Selectable On set map redraw on Run Menu Command 1702 Create Pline 2 (0.969233,52.277931) (1.281258,52.121166) pen makepen( 2, 93, blue) _________________________________ This all works but, as I said, quickly disappears. All I need is some guidance to get off the ground and I'm OK. If you could possibly help then please get in touch. If not, then at least thanks for reading this. TIA Terry McDonnell (England) ******************************************************************** This email may contain information which is privileged or confidential. If you are not the intended recipient of this email, please notify the sender immediately and delete it without reading, copying, storing, forwarding or disclosing its contents to any other person Thank you Check us out at http://www.syntegra.com ********************************************************************
