ObjectARX

ObjectARX

Reply
Mentor
maisoui
Posts: 151
Registered: ‎12-07-2009
Message 1 of 2 (309 Views)
Accepted Solution

How display string in OPM (property palette with COM wrapper)?

309 Views, 1 Replies
04-13-2012 02:39 AM

Hi,

 

I'm trying to display a string in the property palette within a COM object (OPM wrapper). I tried a lot of codes, but cell remain empty. Here's my code:

 

idl:

[propget, id(1), helpstring("property name")] HRESULT name([out, retval] VARIANT *pVal);

 

wrapper header:

OPMPROP_ENTRY(0, 0x00001, PROPCAT_Misc, 0, 0, 0, _T(""), 0, 1, IID_NULL, IID_NULL, "")

STDMETHOD(get_name)(VARIANT * pVal);

 

wrapper implementation:

GetElementValue(...)

{

...

if(dispID == DISPID_PP_NAME)
    {
        CComVariant var;
        get_name(&var);
        BSTR str(var.bstrVal);
        pVarOut->vt = VT_BSTR;
        pVarOut->bstrVal = str;

        return S_OK;
    }

...

}

 

STDMETHODIMP get_name(VARIANT * pVal)
{
    try
    {
        AcAxDocLock lock(m_objId);
        if(lock.lockStatus())
            return (E_ACCESSDENIED);
    
        AcDbObjectPointer<BcModelViewportEntity> pModelViewport(m_objId, AcDb::kForRead);
        if(pModelViewport.openStatus() != Acad::eOk)
            return E_ACCESSDENIED;

        CComBSTR str(L"HELLO WORLD");
        str.CopyTo(pVal);
    }
    catch(const HRESULT hr)
    {
        Error(_T("An error occurred. Check the input params."));
        return hr;
    }

    return S_OK;
}

 

 

Does anybody have a solution? Any suggestions are welcomed.

Regards,

Jonathan

--
Jonathan

Found a solution. You do not need to use a VARIANT but directly a BSTR and it works perfectly.

Regards,

Jonathan

 

Mentor
maisoui
Posts: 151
Registered: ‎12-07-2009
Message 2 of 2 (305 Views)

Re: How display string in OPM (property palette with COM wrapper)?

04-13-2012 05:21 AM in reply to: maisoui

Found a solution. You do not need to use a VARIANT but directly a BSTR and it works perfectly.

Regards,

Jonathan

 

--
Jonathan
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.