Ian,

Thanks for the additional infobut I am still having trouble with this. I
have carried out the following process:

 1.. Create a standard windows project with a form as the startup object
and add a reference to the MapInfo Automation Library Type.
 2.. Add a COMClass class as the MapInfo callback object (use the VS.NET
template which provides all the GUIDs and registers the application for COM
Interop). Add procedures and IDs for handling the MapInfo Shortcut Menu and
Custom Tools.
 3.. Add a module containing MapInfo constant declarations.
 4.. In the Startup form:
·         create the MapInfo object and instantiate it
·         create an instance of the MapInfo callback object (COMClass) and
reference it to MapInfo with MapInfoObject.SetCallBack
·         create the Shortcut Menu and Custom Tools - point them to the
handler procedures and IDs in the callback object
·         open a MapInfo table

At this point all functions provided by the Shortcut Menu and Custom Tools
that interact with the displayed MapInfo table (eg, select, zoom in and out,
and pan) work. What doesn't work is a MapInfo object query function that
intitially gets the coordinates of the cursor. The coordinates are obtained
from the Map Window by the Custom Tool handler in the COMClass and can be
displayed in the Windows Application using MessageBox.Show (the MessageBox
does not initially appear in front of the open windows until the fourth time
it is invoked) but the COMClass will not write them to the Text property of
a Text Box control in the Windows application.

I have tried adding routines as described in the MSDN Callback Sample that you gave me the reference to
but they do not make any difference - but then I do not completely
understand how to relate them to the MapInfo context so my implementation is
probably suspect.

Without wishing to take up too much of your time is there anything else you
can think of that I can try?

Thanks

David
=========================
David Hebblethwaite


----- Original Message ----- From: "SCISOFT" <[EMAIL PROTECTED]>
To: "'David Hebblethwaite'" <[EMAIL PROTECTED]>;
<[email protected]>
Sent: Thursday, June 01, 2006 2:10 PM
Subject: RE: [MI-L] Callbacks with VB.NET2005


David

Sorry, an important omission in my earlier very sketchy post was the need
to
register for COM in the .NET assembly (and, I don't know what's in your
LibPinvokelib.dll).

Make sure you generate your own GUIds (there's a good reason for this
extra
complexity, too).

There was an explicit example in a MapInfo-L thread here, earlier this
year,
where (as I recall, because I haven't searched and confirmed this) it was
remarked that it's important not to create forms within the callback
assembly (as you would expect - can interrupt the OLE process).

Also VS2005 sometimes baulks at Debug runs - better to build, then run the
EXE separately I think.

Sorry to be a bit vague, since I used VS2003 and callbacks for a few tests
with MI, about 12 months ago.

I commonly use .NET with Manifold v6.5 (which is a GIS program that runs
with the .NET Framework v1.1 - v7.0 is .NET Framework v2.0). There aren't
such problems / intricacies involved with Manifold.

You're right - a nice article and code example for using callbacks with MI
is needed.

Ian Thomas
GeoSciSoft - Perth, Australia


_______________________________________________
MapInfo-L mailing list
[email protected]
http://www.directionsmag.com/mailman/listinfo/mapinfo-l

Reply via email to