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

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

1 REPLY 1
SOLVED
Reply
Message 1 of 2
maisoui
726 Views, 1 Reply

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

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
1 REPLY 1
Message 2 of 2
maisoui
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

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

Post to forums  

Autodesk Design & Make Report

”Boost