ObjectARX

Reply
Distinguished Contributor
maisoui
Posts: 127
Registered: ‎12-07-2009
Message 1 of 3 (108 Views)

How overriding correctly GetDisplayName (OPM) ?

108 Views, 2 Replies
08-13-2013 03:14 AM

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
Distinguished Mentor
owenwengerd
Posts: 593
Registered: ‎08-06-2002
Message 2 of 3 (95 Views)

Re: How overriding correctly GetDisplayName (OPM) ?

08-13-2013 06:44 AM 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
Distinguished Contributor
maisoui
Posts: 127
Registered: ‎12-07-2009
Message 3 of 3 (91 Views)

Re: How overriding correctly GetDisplayName (OPM) ?

08-13-2013 06:59 AM in reply to: owenwengerd

Hi Owen,

 

Thank you for your answer. Your solution works.

Maybe there is a easier (lighter) solution?

 

Regards,

Jonathan

 

--
Jonathan

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community