How overriding correctly GetDisplayName (OPM) ?

How overriding correctly GetDisplayName (OPM) ?

maisoui
Advocate Advocate
1,241 Views
4 Replies
Message 1 of 5

How overriding correctly GetDisplayName (OPM) ?

maisoui
Advocate
Advocate

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
0 Likes
Accepted solutions (1)
1,242 Views
4 Replies
Replies (4)
Message 2 of 5

owenwengerd
Advisor
Advisor
Accepted solution

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
0 Likes
Message 3 of 5

maisoui
Advocate
Advocate

Hi Owen,

 

Thank you for your answer. Your solution works.

Maybe there is a easier (lighter) solution?

 

Regards,

Jonathan

 

--
Jonathan
0 Likes
Message 4 of 5

KIMHENGHOR98
Advocate
Advocate

Could you share me your project example?

0 Likes
Message 5 of 5

KIMHENGHOR98
Advocate
Advocate

I added a COM wrapper for my entity but getdisplayname() method never get called

0 Likes