The FindWindow function in your user32 library will return the current instance of MapInfo. It works by caption so when you first run your create objects or a shell MapInfo you know what your window caption will be so capture the handle then and it remains the same throughout that session. The trick is to capture it right off the bat when you still know what the caption will be. Like Ken I'm not a C++ person usually just VB, TCL, or Lisp. I know very little about C++ but as most Windows .dll's are written in C++ and have a documented C++ API you should be able to capture the current instance via that function.
-----Original Message----- From: Kenn Garroch [mailto:[EMAIL PROTECTED]] Sent: Monday, September 23, 2002 1:48 AM To: [EMAIL PROTECTED] Subject: RE: MI-L calling mapbasic from C++ I should say at the outset that I am not an expert on C++. All of my Mapinfo COM experience is from Visual FoxPro. However, you should be able to use something like createobject("Mapinfo.Application") to start Mapinfo as a COM object (depends on your flavour of C++ i.e. createobject returns the object. You can then use this object to execute MapBasic commands with DO e.g. if your object is called mm then mm.do('Print "Hi"') will execute Mapbasic's print command. mm.visible=true will bring up the Mapinfo application window. The problem I have found with all this is that createobject always starts a new instance of the application. It would be really useful to simply connect to the current instance - so I'm unable to help with the second part of your question. Regards Kenn > -----Original Message----- > From: Martin Tyberg [mailto:[EMAIL PROTECTED]] > Sent: 20 September 2002 18:49 > To: [EMAIL PROTECTED] > Subject: MI-L calling mapbasic from C++ > > > > Hi, > > Is it possible to call a MapBasic program function from > within a DLL. The > setup is the following. I have a DLL that exports a function that is > called by a MapBasic function. The DLL invokes a dialog that receives > input from the user. Based on the input, I would like to call > a MapBasic > function in my MapBasic program to update the mapinfo view. Is there > some way to achieve this? > > Also, is there some way to obtain the current instance of > MapInfo and pass > that instance to a DLL from MapBasic so that a DLL can be a client to > MapInfo during the execution of the DLL function call? > > Thanks. > > Martin > > > --------------------------------------------------------------------- > List hosting provided by Directions Magazine | www.directionsmag.com | > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: > [EMAIL PROTECTED] > Message number: 3175 > --------------------------------------------------------------------- List hosting provided by Directions Magazine | www.directionsmag.com | To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Message number: 3196
