SelectionChange(NewSelection,OldSelection) in VC++

VC_Man
01-03-2007, 09:41 AM
I thaught this thread wasn't necessary, but after reading some articles here, I finally decided to open a new thread anyway.

I've read this forum: http://www.mapforums.com/catch-mappoint-events-using-c-without-mfc-3866.html

But still have one problem and that is:


OnSelectionChangeControlMap(LPDISPATCH pNewSelection, LPDISPATCH pOldSelection)
{
//HRESULT hr = pNewSelection->QueryInterface(__uuidof(Pushpin),

// Get old selection - if it is a pushpin, hide the notes/caption
if (pOldSelection)
{
CPushpin *pOldPin;
HRESULT hr = pOldSelection->QueryInterface( __uuidof(CPushpin) , (void**)&pOldPin);
if (SUCCEEDED(hr))
{
//some codeprocessing
}
}

// Get new selection - if it is a pushpin, display notes/caption and modify it
if (pNewSelection)
{
CPushpin *pNewPin;
HRESULT hr = pNewSelection->QueryInterface( __uuidof(CPushpin) , (void**)&pNewPin);
if (SUCCEEDED(hr))
{
//some coding
//some coding agian ;)
}
}

}
and the compilor-error is:

'CPushpin' : no GUID has been associated with this object
'CPushpin' : no GUID has been associated with this object
In the forum I've read, they used Pushpin instead of CPushpin.
I also tried with 'Pushpin', but it didn't matter.
So does someone know how to get the right GUID of Pushpin?? I'm not a specialist in COM, only understand what's going on a little.

Wilfried
01-03-2007, 11:08 AM
Hi,

I assume you have to find it in some #include file. But I never worked with MapPoint in VC++, so someone else has to drop in here.

VC_Man
01-04-2007, 02:37 AM
I've solved the problem, maybe someone else can use it too!
Wtih __uuidof(GUID), this function needs some reference to find out what the GUID is. In Google you can find what GUID is (is a unique ID for a com-object or interface ID of an object: GlobalUniqueIDentifier). Anyway, in my previous snippet of code it needs the ID of Pushpin object.

What I did was give the function __uuidof() the parameter of the class CPushpin, or an instance of CPushpin. But CPushpin has a member pointer to a Dispatch of the Pushpin COM object. Actually, CPushpin is a wrapperclass of Pushpin COM object, I mean in C++/VC++. So you need the member CPushpin::m_lpDispatch to get to the interfaces of Pushpin COM object.


Anyway, the result is: __uuidof(Pushpin::m_lpDispatch)

Good luck!
Btw, thanks Wilfried :)

Wilfried
01-04-2007, 08:23 AM
Hi,

Thank you also for feedback as this for sure benefit others.

 
Web mp2kmag.com
mapforums.com