I haven't actually tried compiling this, but I think it should be OK and
should point you in the right direction.

Basically you need to understand how COM works before to do this. In VB you
tend to use the IDispatch interface to do things and VB handles AddRef and
Release calls for you. C++ can use IDispatch, but it is easier to use
MapInfos' custom interfaces.

Good luck!!

Gavin

#include <atlbase.h>
#import "mapinfow.exe" named_guids raw_interfaces_only
rename_namespace("MapInfo")


// Set globinfo=3Dmapinfo.MBApplications(1).MBGlobals
void GetGlobals( MapInfo::IMapInfo* p3DMapInfo, MapInfo::IMBGlobals**
ppGlobals )
{
        IDispatch* pDisp;
        pDisp = p3DMapInfo->get_MBApplications();
        if( pDisp ) // You don't have to do all these checks - but it may stop the
program crashing!
        {
                CComQIPtr<MapInfo::IMBApplications> pApps( pDisp );
                pDisp->Release();

                if( pApps != NULL )
                {
                        pDisp = pApps->Item( CComVariant( 1L ) );
                        if( pDisp )
                        {
                                pDisp->QueryInterface( __uuidof( MapInfo::IMBGlobals ),
reinterpret_cast<void**>( ppGlobals ) );
                                pDisp->Release();
                        }
                }
        }
}


// old_value=3Dglobinfo("g_status").Value
BSTR Get_G_Status_Value()
{
        BSTR pVal = NULL;
        CComPtr<MapInfo::IMBGlobals> pGlobals;
        GetGlobals( p3dMapInfo, &pGlobals );
        if( pGlobals != NULL )
        {
                IDispatch* pDisp;
                pDisp = pGlobals->Item( CComVariant( L"g_status" ) );
                if( pDisp )
                {
                        CComQIPtr<MapInfo::IMBGlobal> pGlobal( pDisp );
                        if( pGlobal != NULL )
                        {
                                pVal = pGlobal->Value();
                        }
                }
        }
        return pVal;
}


-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of porress
Sent: 01 March 2002 00:22
To: [EMAIL PROTECTED]
Subject: MI-L DMIMapGen on VISUAL C++




I need help, I want to do this funcition but in Visual C++

How to do his ?????

/////////////////////////////////////////////////////////////////////////=
////
Dim globinfo as Object
Dim old_value as integer

Set globinfo=3Dmapinfo.MBApplications(1).MBGlobals
old_value=3Dglobinfo("g_status").Value
globinfo("g_status")=3Dold_value+1

/////////////////////////////////////////////////////////////////////////=
/
BUT IN VISUAL C++



_______________________________________________________________________
List hosting provided by Directions Magazine | www.directionsmag.com |
To unsubscribe, send e-mail to [EMAIL PROTECTED] and
put "unsubscribe MapInfo-L" in the message body.




_______________________________________________________________________
List hosting provided by Directions Magazine | www.directionsmag.com |
To unsubscribe, send e-mail to [EMAIL PROTECTED] and
put "unsubscribe MapInfo-L" in the message body.

Reply via email to