本文整理汇总了C++中COleSafeArray::GetOneDimSize方法的典型用法代码示例。如果您正苦于以下问题:C++ COleSafeArray::GetOneDimSize方法的具体用法?C++ COleSafeArray::GetOneDimSize怎么用?C++ COleSafeArray::GetOneDimSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类COleSafeArray
的用法示例。
在下文中一共展示了COleSafeArray::GetOneDimSize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: __declspec
void __declspec(dllexport) __stdcall FillLocalArray(SequenceContext *seqContext, short *errorOccurred, long *errorCode, char errorMsg[1024])
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
double * numArray = NULL;
unsigned int numElements;
double numCycles = 2.0;
PropertyObjectPtr seqContextPOPtr;
TRY
// Set sequence context as a property object
seqContextPOPtr = seqContext->AsPropertyObject();
// The following code shows how to accesses properties via the ActiveX Automation API
if (seqContextPOPtr->Exists("Locals.NumericArray",0))
{
// Create a Safe Array from the VARIANT which contains a
// copy of the Locals.NumericArray.
COleSafeArray safeArray;
safeArray.Attach(seqContextPOPtr->GetValVariant("Locals.NumericArray",0));
// Check the size of the array of data - assuming 1D array
numElements = safeArray.GetOneDimSize();
// Lock array for data access and get a pointer to the data.
// (assuming it's an array of doubles)
safeArray.AccessData((void**)&numArray);
// Create sine pattern
for (unsigned int i=0; i<numElements; i++)
numArray[i] = sin((2*3.14) * i *numCycles/ numElements);
// unlock array
safeArray.UnaccessData();
// Set the value of the property the lookupString parameter specifies with a variant.
// Use this method to set the value of an entire array at once.
seqContextPOPtr->SetValVariant("Locals.NumericArray", 0, safeArray);
}
CATCH(COleDispatchException, e)
*errorOccurred = TRUE;
_mbsnbcpy_s((unsigned char *)errorMsg, 1024, (unsigned char *)LPCTSTR(e->m_strDescription), 1024 - 1);
*(errorMsg + (1024 - 1)) = '\0';
*errorCode = e->m_scError;
AND_CATCH(CMemoryException, e)
*errorOccurred = TRUE;
e->GetErrorMessage(errorMsg, 1024);
*(errorMsg + (1024 - 1)) = '\0';
*errorCode = TS_Err_OutOfMemory;
END_CATCH
}
示例2: CInstrNotifySink_Found
/* Called when an instrument is located after calling m_pInstrObj->Open()
* @param pInstr Instrument located
*/
void CSubmitOrderDialog::CInstrNotifySink_Found(XTAPI::ITTInstrObj* pInstr)
{
m_StatusBar = (LPCSTR)"Instrument found.";
// Populate the UI with the instrument information.
m_ExchangeBox = (LPCSTR)pInstr->Exchange;
m_ProductBox =(LPCSTR)pInstr->Product;
m_ContractBox = (LPCSTR)pInstr->Contract;
m_ProdTypeBox = (LPCSTR)pInstr->ProdType;
// Create a TTOrderProfile to query for the Customer list
XTAPI::ITTOrderProfilePtr orderProfile;
orderProfile.CreateInstance(__uuidof(XTAPI::TTOrderProfile));
// Populate the Customer ComboBox
COleSafeArray* lpCustomers = new COleSafeArray(orderProfile->Customers);
BSTR customer;
for (long i = 0L; i < (long)lpCustomers->GetOneDimSize(); i++)
{
lpCustomers->GetElement(&i, &customer);
m_CustomerCombo.AddString(CString(customer));
}
// Release TTOrderProfile
orderProfile = NULL;
// delete the array
delete lpCustomers;
lpCustomers = NULL;
// select the first customer in the list.
m_CustomerCombo.SetCurSel(0);
// Create the TTOrderSet
if (SUCCEEDED(m_pOrderSet.CreateInstance(__uuidof(XTAPI::TTOrderSet))))
{
// Set NetLimits to false.
m_pOrderSet->Set("NetLimits",0L);
// Open the TTOrderSet to allow orders to be placed.
m_pOrderSet->Open(true);
}
// Enable the controls on the form
m_PriceControl.EnableWindow(true);
m_QuantityControl.EnableWindow(true);
m_StopPriceControl.EnableWindow(true);
m_CustomerCombo.EnableWindow(true);
m_OrderTypeCombo.EnableWindow(true);
m_BuyButton.EnableWindow(true);
m_SellButton.EnableWindow(true);
// Call after updating the AFX_DATA fields
UpdateData(false);
}