TurboCAD Forums

The Ultimate Resource for TurboCAD Knowledge

Register
 
The purpose of these forums is to discuss TurboCAD.  Please keep the discussion of other products to compatibility issues or how the other software’s can be used with TurboCAD.


Can I use a COleSafeArray as a property? I can add it but I can't get it back.
Read 1717 times
* December 24, 2014, 09:44:08 AM
In the following code "res = pData->get_Value(0,&varValue);" returns E_FAIL.


HRESULT SetProperty (IGraphic* pGraphic, CString Name, COleSafeArray value, COleVariant ReadOnly )
{
   if (pGraphic==(IGraphic*)NULL) return E_POINTER;
   Properties* pProp = NULL;
   HRESULT res = pGraphic->get_Properties(&pProp);
   if (SUCCEEDED(res))
   {
      Property* pData = NULL;
      res = pProp->get_Item(COleVariant(Name),&pData);
      if (SUCCEEDED(res))
      {
         pData->put_Value(0, value);
         pData->Release();
         return res;
      }
      res = pProp->Add(Name.AllocSysString(),&value,&ReadOnly,varMissed,&pData);
      if (SUCCEEDED(res))
      {
         // test
         COleSafeArray varValue;
         res = pData->get_Value(0,&varValue);
         pData->Release();
      }
      pProp->Release();
   }
   return res;
}

Logged