本文整理汇总了C++中wxVariant::SetData方法的典型用法代码示例。如果您正苦于以下问题:C++ wxVariant::SetData方法的具体用法?C++ wxVariant::SetData怎么用?C++ wxVariant::SetData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wxVariant
的用法示例。
在下文中一共展示了wxVariant::SetData方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
WXDLLEXPORT bool
wxConvertOleToVariant(const VARIANTARG& oleVariant, wxVariant& variant, long flags)
{
bool ok = true;
if ( oleVariant.vt & VT_ARRAY )
{
if ( flags & wxOleConvertVariant_ReturnSafeArrays )
{
variant.SetData(new wxVariantDataSafeArray(oleVariant.parray));
}
else
{
switch (oleVariant.vt & VT_TYPEMASK)
{
case VT_I2:
ok = wxSafeArray<VT_I2>::ConvertToVariant(oleVariant.parray, variant);
break;
case VT_I4:
ok = wxSafeArray<VT_I4>::ConvertToVariant(oleVariant.parray, variant);
break;
case VT_R4:
ok = wxSafeArray<VT_R4>::ConvertToVariant(oleVariant.parray, variant);
break;
case VT_R8:
ok = wxSafeArray<VT_R8>::ConvertToVariant(oleVariant.parray, variant);
break;
case VT_VARIANT:
ok = wxSafeArray<VT_VARIANT>::ConvertToVariant(oleVariant.parray, variant);
break;
case VT_BSTR:
{
wxArrayString strings;
if ( wxSafeArray<VT_BSTR>::ConvertToArrayString(oleVariant.parray, strings) )
variant = strings;
else
ok = false;
}
break;
default:
ok = false;
break;
}
if ( !ok )
{
wxLogDebug(wxT("unhandled VT_ARRAY type %x in wxConvertOleToVariant"),
oleVariant.vt & VT_TYPEMASK);
variant = wxVariant();
}
}
}
else if ( oleVariant.vt & VT_BYREF )
{
switch ( oleVariant.vt & VT_TYPEMASK )
{
case VT_VARIANT:
{
VARIANTARG& oleReference = *((LPVARIANT)oleVariant.byref);
if (!wxConvertOleToVariant(oleReference,variant))
return false;
break;
}
default:
wxLogError(wxT("wxAutomationObject::ConvertOleToVariant: [as yet] unhandled reference %X"),
oleVariant.vt);
return false;
}
}
else // simply type (not array or reference)
{
switch ( oleVariant.vt & VT_TYPEMASK )
{
case VT_ERROR:
variant.SetData(new wxVariantDataErrorCode(oleVariant.scode));
break;
case VT_CY:
variant.SetData(new wxVariantDataCurrency(oleVariant.cyVal));
break;
case VT_BSTR:
{
wxString str(wxConvertStringFromOle(oleVariant.bstrVal));
variant = str;
}
break;
case VT_DATE:
#if wxUSE_DATETIME
{
SYSTEMTIME st;
VariantTimeToSystemTime(oleVariant.date, &st);
wxDateTime date;
date.SetFromMSWSysTime(st);
variant = date;
}
#endif // wxUSE_DATETIME
break;
//.........这里部分代码省略.........
示例2: if
WXDLLEXPORT bool
wxConvertOleToVariant(const VARIANTARG& oleVariant, wxVariant& variant)
{
bool ok = true;
if ( oleVariant.vt & VT_ARRAY )
{
// TODO: We currently return arrays as wxVariant of the list type
// containing the flattened form of array but we should allow
// getting it as wxVariantDataSafeArray instead. Doing this is
// simple, we'd just need to do something like this:
//
// if ( oleVariant.parray && SafeArrayGetDim(oleVariant.parray) > 1 )
// {
// variant.SetData(new wxVariantDataSafeArray(oleVariant.parray));
// }
//
// but currently we don't do it for compatibility reasons.
switch (oleVariant.vt & VT_TYPEMASK)
{
case VT_I2:
ok = wxSafeArray<VT_I2>::ConvertToVariant(oleVariant.parray, variant);
break;
case VT_I4:
ok = wxSafeArray<VT_I4>::ConvertToVariant(oleVariant.parray, variant);
break;
case VT_R4:
ok = wxSafeArray<VT_R4>::ConvertToVariant(oleVariant.parray, variant);
break;
case VT_R8:
ok = wxSafeArray<VT_R8>::ConvertToVariant(oleVariant.parray, variant);
break;
case VT_VARIANT:
ok = wxSafeArray<VT_VARIANT>::ConvertToVariant(oleVariant.parray, variant);
break;
case VT_BSTR:
{
wxArrayString strings;
if ( wxSafeArray<VT_BSTR>::ConvertToArrayString(oleVariant.parray, strings) )
variant = strings;
else
ok = false;
}
break;
default:
ok = false;
break;
}
if ( !ok )
{
wxLogDebug(wxT("unhandled VT_ARRAY type %x in wxConvertOleToVariant"),
oleVariant.vt & VT_TYPEMASK);
variant = wxVariant();
}
}
else if ( oleVariant.vt & VT_BYREF )
{
switch ( oleVariant.vt & VT_TYPEMASK )
{
case VT_VARIANT:
{
VARIANTARG& oleReference = *((LPVARIANT)oleVariant.byref);
if (!wxConvertOleToVariant(oleReference,variant))
return false;
break;
}
default:
wxLogError(wxT("wxAutomationObject::ConvertOleToVariant: [as yet] unhandled reference %X"),
oleVariant.vt);
return false;
}
}
else // simply type (not array or reference)
{
switch ( oleVariant.vt & VT_TYPEMASK )
{
case VT_ERROR:
variant.SetData(new wxVariantDataErrorCode(oleVariant.scode));
break;
case VT_CY:
variant.SetData(new wxVariantDataCurrency(oleVariant.cyVal));
break;
case VT_BSTR:
{
wxString str(wxConvertStringFromOle(oleVariant.bstrVal));
variant = str;
}
break;
case VT_DATE:
#if wxUSE_DATETIME
{
SYSTEMTIME st;
VariantTimeToSystemTime(oleVariant.date, &st);
wxDateTime date;
date.SetFromMSWSysTime(st);
variant = date;
//.........这里部分代码省略.........