在VS2013、MFC平台下,使用chart控件中的chart2DData对象的CopyXVectorIn、CopyYVectorIn等方法报错
“Object type mismatch”。源代码如下
VARIANT varChunk;
SAFEARRAY *psa; //使用数组整理读取的数据
SAFEARRAYBOUND rgsabound[1];
rgsabound[0].cElements = 5; //设置数组的大小
rgsabound[0].lLbound = 0;
psa = SafeArrayCreate(VT_R8, 1, rgsabound); //创建SafeArray数组
double *pData = new double[5];
for (long i = 0; i < 5;++i)
{
pData = i * 2;
::SafeArrayPutElement(psa, &i, pData + i);
}
varChunk.vt = VT_R8 | VT_ARRAY; //数组类型
varChunk.parray = psa;
m_GroupCollection = m_Chart.GetChartGroups();
m_ChartGroup = m_GroupCollection.get_Item(_variant_t(1L));
m_Data = m_ChartGroup.GetData();
m_Data.CopyYArrayIn(varChunk);
请教以上问题如何解决? |
|