MapPoint Forums

MapForums

Community of VE/MapPoint Users and Developers




Problem calling AddPolyline in C++

This is a discussion on Problem calling AddPolyline in C++ within the Development forums, part of the MapPoint 2006/2009 Discussion category; I'm using Variants for calling MapPoint functions and I'm having all kind of problems when calling the AddPolyline function. Basically ...


Go Back   MapPoint Forums > Map Forums > MapPoint 2006/2009 Discussion > Development

Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 07-23-2008
Junior Member
White Belt
 
Join Date: Jul 2008
Posts: 2
Problem calling AddPolyline in C++

I'm using Variants for calling MapPoint functions and I'm having all kind of problems when calling the AddPolyline function.
Basically I create a SafeArray where I store all the locations (2 for this example)
and after that I call the AddPolyline function with that array. When I make that call the program crashes.

Anybody has any idea where it may be the problem?

Thanks

Code:
    Variant oMap;
    Variant oApp;

    OleContainer->Visible = false;

    OleContainer->DestroyObject();
    OleContainer->CreateObject("MapPoint.Map",false);
    oMap  = OleContainer->OleObject;
    oApp =  oMap.Exec (PropertyGet("Application"));


    SAFEARRAY *pSA;
    SAFEARRAYBOUND aDim[1];    // a one dimensional array
    aDim[0].lLbound= 0;
    aDim[0].cElements= 2;
    pSA= SafeArrayCreate(VT_VARIANT,1,aDim);  // create a 1D SafeArray of VARIANTS

    HRESULT hr= S_OK;
    if (pSA != NULL)
    {
      long aLong[1];
      for (long i= aDim[0].lLbound; i< (aDim[0].cElements + aDim[0].lLbound); i++)
      {
          Variant oloc = oMap.Exec ( Function("GetLocation") << 38.8186 << -77.1361 << 0.1  );
          aLong[0]= i;
          if (hr == SafeArrayPutElement(pSA, aLong, &oloc))
          {
               int a=5;
          }
      }
    }

    VARIANT v;
    VariantInit(&v);
    v.vt = VT_BYREF|VT_ARRAY;
//    v.pparray = &pSA;
    v.parray = pSA;

    Variant myShapes2 =  oMap.Exec(PropertyGet("Shapes"));
    myShapes2.Exec ( Function("AddPolyline") << v );

    OleContainer->Visible = true;
    OleContainer->DoVerb(ovShow);
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #2 (permalink)  
Old 07-24-2008
Senior Member
Black Belt
 
Join Date: Nov 2004
Posts: 2,055
Re: Problem calling AddPolyline in C++

Hi,

Can you tell us what you mean by 'crash'? Do you have an error or exception error? What is the error or error message?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3 (permalink)  
Old 07-24-2008
Junior Member
White Belt
 
Join Date: Jul 2008
Posts: 2
Re: Problem calling AddPolyline in C++

Quote:
Originally Posted by Wilfried View Post
Hi,

Can you tell us what you mean by 'crash'? Do you have an error or exception error? What is the error or error message?

Thanks for your reply.
I get an error that says 'The parameter is incorrect'
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4 (permalink)  
Old 07-25-2008
Senior Member
Black Belt
 
Join Date: Nov 2004
Posts: 2,055
Re: Problem calling AddPolyline in C++

Hi,

I'm not sure. But you put the address of oLoc to the array (&oLoc), I'm not sure this is correct. Also can you test if oLoc is valid Location? You can do this for example by placing a pushpin with the same oLoc or so.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5 (permalink)  
Old 3 Weeks Ago
Junior Member
White Belt
 
Join Date: Apr 2006
Posts: 5
Re: Problem calling AddPolyline in C++

This is from one of my mapping integration applications:

Quote:
/*
Sweet Jesus this was a pain in the ass to get right.
MapPoint doesn't want a typical variant array of integers,
rather it wants a variant array of variant objects, with
each variant object holding an integer.

Without this indirection, MapPoint simply throws the
dreaded "The parameter is incorrect" error message.
*/
VARIANT larray_to_varray(long la[], long size = 5) {
#pragma warning(disable: 4267)
#pragma warning(disable: 4018)
COleSafeArray varArray;
DWORD elements[] = { size };
varArray.Create(VT_VARIANT, 1, elements);
for (long i = 0; i < size; i++) {
_variant_t v(la[i]);
varArray.PutElement(&i, &v);
}
return varArray.Detach();
}

Last edited by Eric Frost; 2 Weeks Ago at 02:02 PM. Reason: remove offending smilie
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

Thread Thread Starter Forum Replies Last Post
How do I use AddPolyline method in Delphi stephenmillington Development 4 09-20-2007 12:52 PM
Addpolyline from a dataset micheln MapPoint 2006/2009 Discussion 3 05-04-2007 06:49 AM
AddPolyLine (s) array problem FreddyD MapPoint 2006/2009 Discussion 1 12-20-2006 12:45 PM
Shapes.AddPolyline is very slow tdaffin MapPoint 2006/2009 Discussion 4 01-27-2006 07:08 AM
addpolyline Anonymous Wish List 2 04-25-2003 03:50 PM


All times are GMT -5. The time now is 01:44 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
MP2K Magazine
Visitor Map

Ski Holidays Andorra
Ski holidays in Andorra offer value for money right across the board. Clothes, meals and accommodation are great value with duty free prices. Book great value ski holidays today.

City Break Europe
Take a city break in Europe. Travel Counsellors can help plan and book your European city break.

Holidays to Cuba
Situated between Jamaica and the Bahamas, Cuba has a delightful tropical climate and warm, clear waters with beaches of white sand. Check for cheap holidays to Cuba.

Holidays to Jamaica
Holidays to Jamaica are about taking things easy. Forget your watch and chill out beneath the clear Jamaican sky.

Cheap Morocco Holidays
Cheap Morocco holidays may be the answer to your cheap holiday search. With sunshine throughout most of the year it can be great value if you avoid the peak season. Why not include a trip to the small tranquil town of Chefchaouen Tangier in your visit?

Compare Prices
Travel.co.uk makes it easy for you to compare prices from hundreds of UK based travel companies.

Holidays in Fuerteventura
Need a break? Go to the Canary Islands! Find information on holidays in Fuerteventura at On The Beach.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51