MapPoint Forums

MapForums

Community of VE/MapPoint Users and Developers




C++ and passing Variant Arrays

This is a discussion on C++ and passing Variant Arrays within the MapPoint 2006/2009 Discussion forums, part of the Map Forums category; Mappoint has a number of methods that require ArrayOfFields: These Include: ImportData LinkData ImportTerritories LinkTerritories SetFieldsVisibleInBalloon My problem is I ...


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

Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read



Click here to register

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-27-2004
Senior Member
Black Belt
 
Join Date: Jul 2002
Posts: 5,138
C++ and passing Variant Arrays

Mappoint has a number of methods that require ArrayOfFields: These Include:

ImportData
LinkData
ImportTerritories
LinkTerritories
SetFieldsVisibleInBalloon

My problem is I don't seem to be able to create the Variant array properly
Has anyone had any experience with this problem?
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 10-28-2004
Winwaed's Avatar
Mapping-Tools.com
Red Belt
 
Join Date: Feb 2004
Posts: 918
Blog Entries: 11
Hi Garry,

After our emails, I remembered a program I wrote that did work with fields. I've had a look at it, and it only queries the fields of existing pushpins. I don't use ArrayOfFields, but if you think it would help I could post it. (I use the getItem method on a Fields object)

Could the polyline/polygon variant code be modified so that they pass "an array of Field" objects rather than "array of Location" objects?


Richard
__________________
Winwaed Software Technology LLC
http://www.winwaed.com
See http://www.mapping-tools.com for MapPoint Tools
See the Geoweb Guru for online mapping
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 10-28-2004
Senior Member
Black Belt
 
Join Date: Jul 2002
Posts: 5,138
C++ Variants

Alas - that is precisely where I started - I've been trying to use the SafeArray code but I get nowhere.
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 10-29-2004
Senior Member
Black Belt
 
Join Date: Jul 2002
Posts: 5,138
C Builder and variants

I have managed to get SetFieldsVisibleInBalloon working using C++.

Deriving some code from Richard Marsden proved to be the solution.

FieldsPtr pFields = pDataSet->Fields;
long i;
int count = pFields->Count;
FieldPtr pField;
Variant index = 0; // CBuilder variant
HRESULT hr;

VARIANT v;
SAFEARRAY FAR* psa;
SAFEARRAYBOUND saBound;

saBound.cElements = count;
saBound.lLbound = 0;
psa = SafeArrayCreate( VT_DISPATCH, 1, &saBound );

VariantInit( &v );
V_VT( &v ) = VT_ARRAY + VT_DISPATCH;
V_ARRAY( &v ) = psa;

for ( i = 0; i < count; i++ )
{
index = i + 1;
pField = pFields->get_Item( index );
hr = SafeArrayPutElement( psa, &i, pField );
}

pDataSet->SetFieldsVisibleInBalloon( v );
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 02-15-2007
Eric Frost's Avatar
Senior Member
Black Belt
 
Join Date: Jul 1992
Posts: 2,530
Blog Entries: 1
Re: C++ and passing Variant Arrays

I realize this is from July '02, but I am trying to use this code and getting stuck with

Code:
 
Variant index = 0; // CBuilder variant
I am using Visual C++. I really just want one Field passed to the DisplayDataMap method for the second parameter, I don't really need an array of fields.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #6 (permalink)  
Old 02-15-2007
Eric Frost's Avatar
Senior Member
Black Belt
 
Join Date: Jul 1992
Posts: 2,530
Blog Entries: 1
Re: C++ and passing Variant Arrays

Here's my code below.

See the second parameter, this is where I get hung up.

It says it will default to the first valid field, so I put the column I want to map as the first field.

How can I simply specify the default for the DataField parameter?

Thanks,
Eric


Code:
 
oDSPtr->DisplayDataMap(MapPoint::geoDataMapTypeMultipleSymbol, NULL, MapPoint::geoShowByDefault,
MapPoint::geoCombineByNone, MapPoint::geoRangeTypeUniqueValues, 
MapPoint::geoRangeOrderDefault, MapPoint::geoColorSchemeDefault, 5);
 
// [ArrayOfCustomValues], [ArrayOfCustomNames], [DivideByField], [ArrayOfDataFieldLabels], [ArrayOfPushpinSymbols]);
 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #7 (permalink)  
Old 02-16-2007
Junior Member
White Belt
 
Join Date: Feb 2007
Posts: 10
Re: C++ and passing Variant Arrays

Hi,
perhaps it helps You:

//from my program
.....
Code:
void CMapPage::ShowParkPoints()
{
try
{
if(m_bShowPark)
{
m_dsParkPoints = m_DataSets.ImportData(m_strParkPointsPath, NULL, 
geoCountryDefault, geoDelimiterDefault, NULL);
m_dsParkPoints.SetSymbol(20);
int nRecordCount = m_dsParkPoints.GetRecordCount ();
if(nRecordCount == 0)
{
//AfxMessageBox (_T("There are no \"Park\" points"), MB_ICONINFORMATION);
return;
}
COleSafeArray saFields;
saFields.CreateOneDim (VT_DISPATCH, 4);
long lIndex[1];
CFields colFields = m_dsParkPoints.GetFields ();
CField objField;
for(int i = 0; i < 4; i ++)
{
lIndex[0] = i;
objField = colFields.GetItem(COleVariant((long) (i + 2)));
saFields.PutElement (lIndex, objField.m_lpDispatch);
}
m_dsParkPoints.SetFieldsVisibleInBalloon (saFields);
m_DataSets.ZoomTo ();
}
else
m_dsParkPoints.Delete();
} //try
catch (COleDispatchException * pExpn)
{
#ifdef _DEBUG
pExpn->ReportError ();
#endif
pExpn->Delete ();
}
}
......
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #8 (permalink)  
Old 02-16-2007
Eric Frost's Avatar
Senior Member
Black Belt
 
Join Date: Jul 1992
Posts: 2,530
Blog Entries: 1
Re: C++ and passing Variant Arrays

Thank you Dr.!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #9 (permalink)  
Old 12-20-2007
Junior Member
White Belt
 
Join Date: Dec 2007
Location: Germany
Posts: 9
Re: C++ and passing Variant Arrays

Hi Dr. Nobody!

I'm still having the same problems. Have you suceeded in adding the fieldlist to ImportData?

Pit

Quote:
Originally Posted by DrNobody View Post
Hi,
perhaps it helps You:

//from my program
.....
Code:
void CMapPage::ShowParkPoints()
{
try
{
if(m_bShowPark)
{
m_dsParkPoints = m_DataSets.ImportData(m_strParkPointsPath, NULL, 
geoCountryDefault, geoDelimiterDefault, NULL);
m_dsParkPoints.SetSymbol(20);
int nRecordCount = m_dsParkPoints.GetRecordCount ();
if(nRecordCount == 0)
{
//AfxMessageBox (_T("There are no \"Park\" points"), MB_ICONINFORMATION);
return;
}
COleSafeArray saFields;
saFields.CreateOneDim (VT_DISPATCH, 4);
long lIndex[1];
CFields colFields = m_dsParkPoints.GetFields ();
CField objField;
for(int i = 0; i < 4; i ++)
{
lIndex[0] = i;
objField = colFields.GetItem(COleVariant((long) (i + 2)));
saFields.PutElement (lIndex, objField.m_lpDispatch);
}
m_dsParkPoints.SetFieldsVisibleInBalloon (saFields);
m_DataSets.ZoomTo ();
}
else
m_dsParkPoints.Delete();
} //try
catch (COleDispatchException * pExpn)
{
#ifdef _DEBUG
pExpn->ReportError ();
#endif
pExpn->Delete ();
}
}
......
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

Tags
arrays, passing, variant


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
Passing a VARIANT for LinkData() method using VC++ geouser MapPoint 2006/2009 Discussion 1 07-15-2006 07:30 AM
How can i find address by passing Lat/Lon as parameter? joesebi MapPoint 2006/2009 Discussion 1 07-09-2003 10:10 AM


All times are GMT -5. The time now is 01:15 AM.


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


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 52 53 54 55