ObjectARX
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How overriding correctly GetDisplayName (OPM) ?

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
maisoui
598 Views, 2 Replies

How overriding correctly GetDisplayName (OPM) ?

Hi,

 

I implemented OPM wrapper for my custom entity and I overrided the method GetDisplayName to specify custom properties names and a custom display name like this:

 

STDMETHODIMP CCustomWrapper::GetDisplayName(DISPID dispId, BSTR * propName)
{
	HRESULT hr = S_OK;

	switch(dispId)
	{	
	case DISPID_...:
		*propName = ::SysAllocString(_T("My property"));
		break;

	case DISPID_DISPLAYNAME:
		*propName = ::SysAllocString(_T("MyCustomEntity"));
		break;

	default:
		hr = IOPMPropertyExtensionImpl<CCustomWrapper>::GetDisplayName(dispId, propName);
		assert(hr == S_OK);
	}

	return hr;
}

 

The problem is that the call to IOPMPropertyExtensionImpl<CCustomWrapper>::GetDisplayName(dispId, propName); always returns E_FAIL. The result is that the name of each common properties of AcDbEntities is not correct. See the images below:

 

opm_getdisplayname_normal.png

 

opm_getdisplayname_custom.png

 

What did I do wrong? In the ObjectARX samples, no call to the parent IOPMPropertyExtensionImpl is made...

 

Regards,

Jonathan

 

--
Jonathan
2 REPLIES 2
Message 2 of 3
owenwengerd
in reply to: maisoui

As far as I know, the only solution is to create a separate wrapper instance (I create one of the base class entity type), then call it's GetDisplayName member function.

 

CComQIPtr<IOPMPropertyExtension> OPEHelper;
OPEHelper.CoCreateInstance( CLSID_AcadLine );

if (dispID >= 0x100 && OPEHelper)
{
	hr = OPEHelper->GetDisplayName(dispID, propName);
	if (SUCCEEDED(hr))
		return S_OK;
}
hr = __super::GetDisplayName(dispID, propName);

 

--
Owen Wengerd
ManuSoft
Message 3 of 3
maisoui
in reply to: owenwengerd

Hi Owen,

 

Thank you for your answer. Your solution works.

Maybe there is a easier (lighter) solution?

 

Regards,

Jonathan

 

--
Jonathan

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost