1. COleSafeArray is the only way to pass data via COM, but I don't quite understand the reason of your question. The example we created was using dynamic array size, as can be seen below,
COleSafeArray csa;
DWORD bounds[2] = {m_nRows, m_nColumns};
csa.Create(VT_R8, 2, bounds);
long index[2];
UINT nLowerBound = nRowStart;
UINT nUpperBound = m_nRows + nRowStart;
for( UINT ii=0; ii < m_nColumns; ii++ )
{
for( UINT jj=0; jj < m_nRows; jj++ )
{
index[0]=jj;
index[1]=ii;
double fVal = 0.0;
if( ii == 0 )
fVal = nLowerBound + jj + 1;
else
fVal = ((nLowerBound + jj + 1) * 10 + ii) * rand()/RAND_MAX;
csa.PutElement(index, &fVal);
}
}
//Put generated numeric data into Origin
m_pClient->SetWorksheet(m_strWksName, csa, nRowStart);
2. As for slower speed then DDE, that might be a different issue. The updating of graphs might be the reason. In DDE, there were realtime mode where the graph will not be redrawn, but only the data is appended to the graph. This mechanism is not yet implemented in the COM data transfer, so you might be seeing a complete redraw of your graph which will be slower. Try making the graph minimized and see if speed is better.
CP
Edited by - cpyang on 04/20/2004 11:05:08 AM