MapPoint Forums

MapForums

Community of VE/MapPoint Users and Developers




AddPushPin() throws exception in VC++

This is a discussion on AddPushPin() throws exception in VC++ within the MapPoint 2006/2009 Discussion forums, part of the Map Forums category; Hi, I have a problem adding pushpins to a map using MS VC ++ 6.0. This is my code: theApp.LockMapPointApp(); ...


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

Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-18-2005
Junior Member
White Belt
 
Join Date: Jan 2005
Posts: 1
AddPushPin() throws exception in VC++

Hi,

I have a problem adding pushpins to a map using MS VC ++ 6.0. This is my code:

theApp.LockMapPointApp();

// Create a new pushpin object to represent the antenna:
pPin = new CPushpin;

// Open the MapPoint map...
// theApp.GetMapPointApp() returns a MapPoint.Application object...
theApp.GetMapPointApp().OpenMap( m_csMapPointFile, FALSE );

// Find the location where the antenna needs to be placed:
CLocation loc;
loc = theApp.GetMapPointApp().GetActiveMap().GetLocation ( dblLatitude, dblLongitude, 0 );

if ( bCenterOn )
// Center on the newly added pin...
loc.GoTo();

try
{
CMap1 map = theApp.GetMapPointApp().GetActiveMap();

// Add the pushpin and set the name (if any)...
if ( ! csName.IsEmpty() )
*pPin = map.AddPushpin( loc, csName );
else
*pPin = map.AddPushpin( loc, "<Nameless>" );
}
catch ( COleDispatchException *ex )
{
dwLastError = ::GetLastError();
iErrNo = errno;

ex->GetErrorMessage( szError, 1024 );
theApp.Log( LOG_MAP_ERROR, m_iId, _T("MapPoint OleDispatchException while adding PushPin: %s"), szError );
}

// Save the pushpin reference instance
...

// Do some settings...
...

theApp.UnlockMapPointApp();

--- End code ---

It is the "*pPin = map.AddPushpin( loc, csName );" line of code that throws the exception.

Any kind of help would be appreciated...

Many thanks,
Radboud

PS: Another application using a MappointControl object works just fine...
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 01-18-2005
Winwaed's Avatar
Mapping-Tools.com
Red Belt
 
Join Date: Feb 2004
Posts: 787
Blog Entries: 5
I usually use MapPoint in C++ without MFC.

I assume csName is an MFC CString?

The problem might be because the COM interface is expecting its own flavour of string (eg. a BSTR), rather than a 'smart CString object'.

I've just looked at my code (non-MFC, and using STL), and I pass an STL string to a MapPoint method by converting it to a (const char*). When receiving data (ie. querying a field) I have to go via VARIANTs.

Note that your hard-coded string constants are also of type (const char*).


Richard
__________________
Winwaed Software Technology LLC
http://www.winwaed.com
See http://www.mapping-tools.com for MapPoint Tools
Pre-Order MapPoint 2009 today: http://www.mapping-tools.com/mappoint2009
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 01-20-2005
Senior Member
Black Belt
 
Join Date: Jul 2002
Posts: 5,138
Instead of define pPin as a pointer and allocate an object then reassign *pPin as you did.
==================
You would define

Pushpin JustPin;

JustPin = map.AddPushpin( loc, (LPCTSTR)csName );

=====================


Let me know if this helps.
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
addpushpin - need help to get started BWard MapPoint 2006/2009 Discussion 7 12-19-2005 02:15 PM
AddPushPin Anonymous MapPoint 2006/2009 Discussion 0 03-01-2004 10:41 AM
addPushpin nringdahl MapPoint 2006/2009 Discussion 1 01-27-2004 09:09 AM
AddPushpin with more data than Loc and name possible? Anonymous MapPoint 2006/2009 Discussion 5 03-17-2003 06:11 PM
AddPushpin Monique MapPoint 2006/2009 Discussion 3 08-20-2002 01:26 AM


All times are GMT -5. The time now is 11:17 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

Half Term Ski Holidays
Have you got half term ski holidays in mind? We may not be mind readers but we can search for great value ski holidays to suit you. Why not try now?

Spain Weather
Check out Spain Weather - Travel Counsellors details information on Spain including, weather, flights and accommodation.

Italy Holiday
An Italy Holiday is full of interesting stuff for the casual tourist and even more for the educated visitor. Check out the latest great deals at dealchecker.co.uk.

Mauritius Holidays
Mauritis holidays are a sun drenched, sense tingling experience of a lifetime. You will find bargain deals on many holidays with us!

Holiday
Searching for the perfect holiday? Well check out ULookUBook online to find out all about your destination and also to book a great value holiday.

Family package holidays
Looking for family package holidays? Book yours now at Travel.co.uk!

Cheap Florida Holidays
You thought American holidays were expensive? No ways! Affordable holidays to Florida, only 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