本文整理汇总了C++中COleVariant类的典型用法代码示例。如果您正苦于以下问题:C++ COleVariant类的具体用法?C++ COleVariant怎么用?C++ COleVariant使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了COleVariant类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ConvertStringToUnsignedInt
/**
* 字符串转换为无符号整数
* @param CString strData 字符串
* @return unsigned int 无符号整数
*/
unsigned int CIPList::ConvertStringToUnsignedInt(CString strData)
{
COleVariant oVariant = strData;
oVariant.ChangeType(VT_UINT);
unsigned int uiData = oVariant.uintVal;
return uiData;
}
示例2: BOOL
void CDlg::OnBnClickedButton5()
{
//Товар-склад
COleVariant vC;
short i;
BeginWaitCursor();
HMODULE hMod;
BOOL bFndC;
CString strFndC;
bFndC = FALSE;
strFndC = _T("");
if(IsEnableRec(ptrRs1)){
i = 0;
vC = GetValueRec(ptrRs1,i);
vC.ChangeType(VT_BSTR);
strFndC = vC.bstrVal;
strFndC.TrimLeft();
strFndC.TrimRight();
bFndC = TRUE;
}
hMod=AfxLoadLibrary(_T("OrdStrg.dll"));
typedef BOOL (*pDialog)(CString,_ConnectionPtr,CString,BOOL);
pDialog func=(pDialog)GetProcAddress(hMod,"startOrdStrg");
(func)(m_strNT, ptrCnn,strFndC,bFndC);
// m_SlpDay.SetDate(t1);
AfxFreeLibrary(hMod);
EndWaitCursor();
}
示例3: OnShowEdit
void CDlg::OnShowEdit(void)
{
COleVariant vC;
short i;
CString strC;
if(ptrRs1->State==adStateOpen){
if(!IsEmptyRec(ptrRs1)){
i = 1; //Сокр наимен
vC = GetValueRec(ptrRs1,i);
vC.ChangeType(VT_BSTR);
m_Edit1 = vC.bstrVal;
m_Edit1.TrimLeft();
m_Edit1.TrimRight();
GetDlgItem(IDC_EDIT1)->SetWindowText(m_Edit1);
i = 2; //Наименование
vC = GetValueRec(ptrRs1,i);
vC.ChangeType(VT_BSTR);
m_Edit2 = vC.bstrVal;
m_Edit2.TrimLeft();
m_Edit2.TrimRight();
GetDlgItem(IDC_EDIT2)->SetWindowText(m_Edit2);
}
}
}
示例4: OnGraphViewInstrumentSetDetour
/**
* 响应仪器图形视图弹出菜单设置迂回道
* @param unsigned int uiInstrumentType 低端仪器类型 1-交叉站;2-电源站;3-采集站
* @param unsigned int uiSN 低端仪器设备号
* @param unsigned int uiInstrumentType 高端仪器类型 1-交叉站;2-电源站;3-采集站
* @param unsigned int uiSN 高端仪器设备号
* @return void
*/
void CTabDetour::OnGraphViewInstrumentSetDetour(unsigned int uiInstrumentTypeLow, unsigned int uiSNLow, unsigned int uiInstrumentTypeHigh, unsigned int uiSNHight)
{
CBCGPGridRow* pRow = NULL;
COleVariant oVariant;
pRow = m_oGridCtrlEdit.GetRow(0);
// 得到BoxType字符串
CString strBoxType = m_pSiteData->GetBoxTypeStringByID(uiInstrumentTypeLow);
oVariant = strBoxType;
pRow->GetItem(0)->SetValue(oVariant);
CString strSNLow;
strSNLow.Format("%d", uiSNLow);
oVariant = strSNLow;
oVariant.ChangeType(VT_BSTR);
pRow->GetItem(1)->SetValue(oVariant);
oVariant = (long)1;
oVariant.ChangeType(VT_BSTR);
pRow->GetItem(2)->SetValue(oVariant);
strBoxType = m_pSiteData->GetBoxTypeStringByID(uiInstrumentTypeHigh);
oVariant = strBoxType;
pRow->GetItem(3)->SetValue(oVariant);
CString strSNHigh;
strSNHigh.Format("%d", uiSNHight);
oVariant = strSNHigh;
oVariant.ChangeType(VT_BSTR);
pRow->GetItem(4)->SetValue(oVariant);
oVariant = (long)1;
oVariant.ChangeType(VT_BSTR);
pRow->GetItem(5)->SetValue(oVariant);
}
示例5: GetPropValue
CString CSpriteSet::GetPropValue(CMFCPropertyGridProperty* pProp)
{
COleVariant vPropValue = pProp->GetValue();
vPropValue.ChangeType(VT_BSTR);
CString strValue = CString(vPropValue.bstrVal);
return strValue;
}
示例6: OnBnClickedButtonReset
/**
* 响应鼠标单击按钮;Reset
* @param void
* @return void
*/
void CTabMute::OnBnClickedButtonReset()
{
CBCGPGridRow* pRow = NULL;
POSITION pos= NULL;
CMuteData oMuteData;
COleVariant oVariant;
pRow = m_oGridCtrlEdit.GetRow(0);
pRow->GetItem(0)->SetValue("");
pRow->GetItem(1)->SetValue("");
m_oGridCtrlList.RemoveAll(); // 列表
int iCount = m_pSiteData->m_oMuteList.m_olsMute.GetCount();
for(int i = 0; i < iCount; i++)
{
pos = m_pSiteData->m_oMuteList.m_olsMute.FindIndex(i);
oMuteData = m_pSiteData->m_oMuteList.m_olsMute.GetAt(pos);
pRow = m_oGridCtrlList.CreateRow(m_oGridCtrlList.GetColumnCount());
oVariant = (long)oMuteData.m_uiLineName;
oVariant.ChangeType(VT_BSTR);
pRow->GetItem(0)->SetValue(oVariant);
oVariant = (long)oMuteData.m_uiPointNb;
oVariant.ChangeType(VT_BSTR);
pRow->GetItem(1)->SetValue(oVariant);
m_oGridCtrlList.AddRow(pRow, FALSE);
}
m_oGridCtrlEdit.AdjustLayout();
m_oGridCtrlList.AdjustLayout();
}
示例7: covOptional
void Cwhu_FaxSettingDlg::Lin_ImportAutoForArr(CString m_FilePath,CStringArray &m_AutoForward)
{
int Number = 0;
//m_DutyArr数组必须足够大//
//导入
CApplication app;
CWorkbook book;
CWorkbooks books;
CWorksheet sheet;
CWorksheets sheets;
CRange range;
LPDISPATCH lpDisp;
//定义变量//
COleVariant covOptional((long)
DISP_E_PARAMNOTFOUND,VT_ERROR);
if (!app.CreateDispatch(_T("Excel.Application")))
{
this->MessageBox(_T("无法创建Excel应用"));
}
books = app.get_Workbooks();
//打开Excel,其中m_FilePath为Excel表的路径名//
lpDisp = books.Open(m_FilePath,covOptional
,covOptional,covOptional,covOptional
,covOptional,covOptional,covOptional
,covOptional,covOptional,covOptional
,covOptional,covOptional,covOptional
,covOptional);
book.AttachDispatch(lpDisp);
sheets = book.get_Worksheets();
sheet = sheets.get_Item(COleVariant((short)1));
CStringArray m_ContentArr;
for (int ItemNum = 2;ItemNum<40;ItemNum++)
{
for (int ColumNum=1;ColumNum<11;ColumNum++)
{
CString m_pos = Lin_GetEnglishCharacter(ColumNum);
CString m_Itempos;
m_Itempos.Format(_T("%d"),ItemNum);
CString m_str = m_pos+m_Itempos;
range = sheet.get_Range(COleVariant(m_str),COleVariant(m_str));
//获得单元格的内容
COleVariant rValue;
rValue = COleVariant(range.get_Value2());
//转换成宽字符//
rValue.ChangeType(VT_BSTR);
//转换格式,并输出//
CString m_content = CString(rValue.bstrVal);
if (m_content!=_T(""))
{
m_AutoForward.Add(m_content);
}
}
}
book.put_Saved(TRUE);
app.Quit();
}
示例8: OnGridCtrlListLButtonDownA
/**
* 响应鼠标单击列表
* @param CBCGPGridCtrl* pGridCtrlEdit 输入行
* @param CBCGPGridCtrl* pGridCtrlList 列表
* @return void
*/
void CTabPage::OnGridCtrlListLButtonDownA(CBCGPGridCtrl* pGridCtrlEdit, CBCGPGridCtrl* pGridCtrlList)
{
CBCGPGridRow* pRow = pGridCtrlList->GetCurSel();
if(NULL != pRow)
{
COleVariant oVariant = pRow->GetItem(0)->GetValue();
oVariant.ChangeType(VT_BSTR);
pGridCtrlEdit->GetRow(0)->GetItem(0)->SetValue(oVariant);
}
}
示例9: OnBnClickedButtonReset
/**
* 响应鼠标单击按钮;Reset
* @param void
* @return void
*/
void CTabTestLimit::OnBnClickedButtonReset()
{
CBCGPGridRow* pRow = NULL;
POSITION pos= NULL;
CTestLimitList* pTestLimitList = NULL;
COleVariant oVariant;
COleVariant oVariantString;
if(1 == m_uiAim) // 测试对象 1-仪器;2-检波器
{
pTestLimitList = &m_pSiteData->m_oTestLimitListInstrument;
}
else if(2 == m_uiAim) // 测试对象 1-仪器;2-检波器
{
pTestLimitList = &m_pSiteData->m_oTestLimitListSensor;
}
pRow = m_oGridCtrlEdit.GetRow(0);
pRow->GetItem(0)->SetValue("");
pRow->GetItem(1)->SetValue("");
pRow->GetItem(2)->SetValue("");
pRow->GetItem(3)->SetValue("");
pRow->GetItem(4)->SetValue("");
m_oGridCtrlList.RemoveAll(); // 列表
int iCount = pTestLimitList->m_olsTestLimit.GetCount();
for(int i = 0; i < iCount; i++)
{
pos = pTestLimitList->m_olsTestLimit.FindIndex(i);
CTestLimitData& oTestLimitData = pTestLimitList->m_olsTestLimit.GetAt(pos);
pRow = m_oGridCtrlList.CreateRow(m_oGridCtrlList.GetColumnCount());
oVariant = (long)oTestLimitData.m_uiNb;
oVariant.ChangeType(VT_BSTR);
pRow->GetItem(0)->SetValue(oVariant);
oVariant = oTestLimitData.m_strDesc;
pRow->GetItem(1)->SetValue(oVariant);
oVariant = oTestLimitData.m_strUnit;
pRow->GetItem(2)->SetValue(oVariant);
oVariantString = m_pSiteData->GetTestTypeStringByID(oTestLimitData.m_uiType);
oVariantString.ChangeType(VT_BSTR);
pRow->GetItem(3)->SetValue(oVariantString);
oVariant = oTestLimitData.m_fLimit;
oVariant.ChangeType(VT_BSTR);
pRow->GetItem(4)->SetValue(oVariant);
m_oGridCtrlList.AddRow(pRow, FALSE);
}
m_oGridCtrlEdit.AdjustLayout();
m_oGridCtrlList.AdjustLayout();
}
示例10: SetDateTime
void CDateRemind::SetDateTime(CString date)
{
COleVariant VariantTime;
VariantTime = date;
VariantTime.ChangeType(VT_DATE);
COleDateTime DateTime = VariantTime;
m_nYear = DateTime.GetYear();
m_nMonth = DateTime.GetMonth();
m_nDay = DateTime.GetDay();
}
示例11: GetValueRec
void CDlg::On32776(void)
{
// Изменить
// UpdateData();
CString strSql,strC;
_variant_t vra;
COleVariant vC;
VARIANT* vtl = NULL;
short IndCol,i;
if(ptrRs1->State==adStateOpen){
if(!IsEmptyRec(ptrRs1)){
i = 0; //Код
vC = GetValueRec(ptrRs1,i);
vC.ChangeType(VT_BSTR);
strC = vC.bstrVal;
strC.TrimRight();
strC.TrimRight();
if(OnOverEdit(IDC_EDIT1,IDC_EDIT2)){
strSql = _T("UT9 ");
strSql+= strC + _T(",'");
strSql+= m_Edit1 + _T("','");
strSql+= m_Edit2 + _T("','");
strSql+= m_strNT + _T("'");
ptrCmd1->CommandText = (_bstr_t)strSql;
ptrCmd1->CommandType = adCmdText;
try{
// AfxMessageBox(strSql);
ptrCmd1->Execute(&vra,vtl,adCmdText);
}
catch(_com_error& e){
AfxMessageBox(e.Description());
}
strSql = _T("QT9");
OnShowGrid(strSql, ptrRs1,ptrCmd1,m_DataGrid1,InitDataGrid1);
if(ptrRs1->State==adStateOpen){
if(!IsEmptyRec(ptrRs1)){
if(!m_Edit1.IsEmpty()){
IndCol = 0;
m_Flg = false;
OnFindInGrid(strC,ptrRs1,IndCol,m_Flg);
m_Flg = true;
}
}
}
}
}
}
return;
}
示例12: OnBnClickedButtonAddA
/**
* @brief 响应鼠标单击按钮;Add
* @note 该函数总是向列表框的后面追加记录。
* @param CBCGPGridCtrl* pGridCtrlEdit 输入行
* @param CBCGPGridCtrl* pGridCtrlList 列表
* @param CList<int, int>* ListNb Nb号队列指针
* @return void
*/
void CGridCtrlOperation::OnBnClickedButtonAddA(CBCGPGridCtrl* pGridCtrlEdit, CBCGPGridCtrl* pGridCtrlList)
{
int i;
int iNb;
COleVariant oEditVariant;
CBCGPGridRow* pRowEdit = NULL; // 输入行
CBCGPGridRow* pRowNew = NULL; // 新行
int iRowID = 0;
CList<int, int> ListNb;
// 得到索引队列,增加操作
if(false == GetIndexListForAdd(pGridCtrlEdit, &ListNb))
{
return;
}
pRowEdit = pGridCtrlEdit->GetRow(0);
while(FALSE == ListNb.IsEmpty())
{
// 得到索引号
iNb = ListNb.RemoveHead();
// 索引号在列表中已经存在
if(NULL != pGridCtrlList->FindRowByData(iNb))
{
continue;
}
pRowNew = pGridCtrlList->CreateRow(pGridCtrlList->GetColumnCount());
pRowNew->SetData(iNb);
oEditVariant.vt = VT_UI4;
oEditVariant.ulVal = iNb;
oEditVariant.ChangeType(VT_BSTR);
pRowNew->GetItem(0)->SetValue(oEditVariant);
for(i = 1; i < pGridCtrlList->GetColumnCount(); i++)
{
oEditVariant= pRowEdit->GetItem(i)->GetValue();
pRowNew->GetItem(i)->SetValue(oEditVariant);
}
pGridCtrlList->AddRow(pRowNew, FALSE);
/*
if(iSelectRowIndex == -1) // 无选中行
{
pGridCtrlList->AddRow(pRowNew, FALSE);
}
else
{
pGridCtrlList->InsertRowAfter(iSelectRowIndex + iRowID, pRowNew, FALSE);
iRowID++;
}*/
}
pGridCtrlList->AdjustLayout();
}
示例13: GetValueForTextField
/**
* @brief 解析文本框的格式
* @note 在文本框中
/ 表示列表框中当前值不会被更改。
V 表示数值 V 将被应用到指定一行或一组行。
V/i 或 V/+i (或 V/-i)表示从 V 开始的步进
(或步减)值将被应用到指定一组行上。
(+ 符号为可选)。
/i 或 /+i (或 /-i)表示步进(或步减)
将被应用到指定一组行的已存在数值上。
* @param COleVariant* pEditVariant 编辑框的内容
* @param COleVariant* pListVariant 文本框的内容
* @param int nIndex 循环次数,如V/i的格式时,用于计算 V + nIndex*i
* @return
*/
COleVariant CGridCtrlOperation::GetValueForTextField(COleVariant* pEditVariant,COleVariant* pListVariant,int nIndex)
{
int nPos;
CString strData;
COleVariant oResultVariant;
try
{ // 格式 V ,不是字符串
if(pEditVariant->vt!=VT_BSTR)
{
return *pEditVariant;
}
strData = *pEditVariant;
// 格式 /
if(!strData.CompareNoCase(_T("/")))
{
return *pListVariant;
}
// 格式 V
nPos = strData.Find('/');
if(nPos<0)
{
return *pEditVariant;
}
else if(nPos ==0) // 解析格式 /i
{
strData.Remove('/');
oResultVariant = strData;
oResultVariant.ChangeType(VT_R4);
pListVariant->ChangeType(VT_R4);
oResultVariant.fltVal = pListVariant->fltVal + nIndex * oResultVariant.fltVal;
return oResultVariant;
}
else // 解析格式 V/i
{
float fValue,fStep;
strData.Replace(_T("/"),_T(" "));
_stscanf_s(LPCTSTR(strData),_T("%f%f"),&fValue,&fStep);
oResultVariant = fValue + nIndex * fStep;
return oResultVariant;
}
}
catch (CException* )
{
oResultVariant.vt = VT_EMPTY;
}
return oResultVariant;
}
示例14: ClearList
// FillList
// Called when a new Target Object Property is Set
// Iterates through the property map and adds the items to the
// List Control
void CPropMapCtrl::FillList()
{
// REVIEW: handle Security Checking when that stuff is done
if (!m_pPropMap)
{
// if the thing is null it means that the list should be emptied
ClearList();
return;
}
HRESULT hr = S_OK;
CString cstrName;
BSTR bstrReturnValue = NULL;
// yes, iterate through properties
VARIANT_BOOL fLastItem = VARIANT_FALSE;
COleVariant varProperty;
hr = m_pPropMap->get_IsEmpty( &fLastItem );
if (FAILED(hr)) goto failexit;
if( ! fLastItem )
{
varProperty.Clear();
hr = m_pPropMap->FirstItem( &bstrReturnValue, &varProperty, &fLastItem );
if (NONSECURITYFAIL(hr))
goto failexit;
while( !(fLastItem == VARIANT_TRUE))
{
// Get the name of the Item in the PropertyMap.
cstrName = bstrReturnValue;
if (SUCCEEDED(hr))
AddVariantItem( varProperty, cstrName );
SAFEFREESTRING(bstrReturnValue);
hr = m_pPropMap->NextItem( &bstrReturnValue, &varProperty, &fLastItem );
if (NONSECURITYFAIL(hr))
goto failexit;
}
}
m_listCtrl.Sort();
failexit:
SAFEFREESTRING(bstrReturnValue);
}
示例15: OnGridCtrlListDblClkA
/**
* 响应鼠标单击双击列表
* @param void
* @return void
*/
void CTabTestSensor::OnGridCtrlListDblClk()
{
OnGridCtrlListDblClkA(&m_oGridCtrlEdit, &m_oGridCtrlList);
CBCGPGridRow* pRow = m_oGridCtrlList.GetCurSel();
if(NULL != pRow)
{
COleVariant oVariant = pRow->GetItem(3)->GetValue();
oVariant.ChangeType(VT_BSTR);
CString AbsoluteSpread = oVariant;
AbsoluteSpread.Replace(";", "\r\n");
GetDlgItem(IDC_EDIT_ABSOLUTESPREAD)->SetWindowText(AbsoluteSpread);
}
}