ObjectARX

Reply
Distinguished Contributor
maisoui
Posts: 131
Registered: ‎12-07-2009
Message 1 of 2 (285 Views)
Accepted Solution

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

285 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
Distinguished Contributor
maisoui
Posts: 131
Registered: ‎12-07-2009
Message 2 of 2 (281 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

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