本文整理汇总了C++中COleVariant函数的典型用法代码示例。如果您正苦于以下问题:C++ COleVariant函数的具体用法?C++ COleVariant怎么用?C++ COleVariant使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了COleVariant函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: COleVariant
//VT_R8
int IllusionExcelFile::GetCellInt(long irow, long icolumn)
{
int num;
COleVariant vresult;
if (already_preload_ == FALSE)
{
CRange range;
range.AttachDispatch(excel_current_range_.get_Item(COleVariant((long)irow), COleVariant((long)icolumn)).pdispVal, true);
vresult = range.get_Value2();
range.ReleaseDispatch();
}
else
{
long read_address[2];
VARIANT val;
read_address[0] = irow;
read_address[1] = icolumn;
ole_safe_array_.GetElement(read_address, &val);
vresult = val;
}
//
num = static_cast<int>(vresult.dblVal);
return num;
}
示例2: ShowInExcel
//关闭打开的Excel 文件,默认情况不保存文件
void IllusionExcelFile::CloseExcelFile(BOOL if_save)
{
//如果已经打开,关闭文件
if (open_excel_file_.IsEmpty() == FALSE)
{
//如果保存,交给用户控制,让用户自己存,如果自己SAVE,会出现莫名的等待
if (if_save)
{
ShowInExcel(TRUE);
}
else
{
//
excel_work_book_.Close(COleVariant(short(FALSE)), COleVariant(open_excel_file_), covOptional);
excel_books_.Close();
}
//打开文件的名称清空
open_excel_file_.Empty();
}
excel_current_range_.ReleaseDispatch();
excel_work_sheet_.ReleaseDispatch();
excel_sheets_.ReleaseDispatch();
excel_work_book_.ReleaseDispatch();
excel_books_.ReleaseDispatch();
}
示例3: mesage_SetPathValue
int mesage_SetPathValue(lua_State* L)
{
CString type = luaL_typename(L,3);
if(type == "string")
{
CString str = luaL_checkstring(L,3);
COleDateTime dt;
if(dt.ParseDateTime(str))
{
cmessage_arg(L,"mesage_SetPathValue")->SetDatumByPath(luaL_checkstring(L,2),COleVariant(dt));
}else{
cmessage_arg(L,"mesage_SetPathValue")->SetDatumByPath(luaL_checkstring(L,2),COleVariant(str));
}
}else if(type == "number")
{
cmessage_arg(L,"mesage_SetPathValue")->SetDatumByPath(luaL_checkstring(L,2),COleVariant(luaL_checknumber(L,3)));
}else if(type == "boolean")
{
VARIANT var;
var.vt = VT_BOOL;
var.boolVal = (lua_toboolean(L,3)==1);
cmessage_arg(L,"mesage_SetPathValue")->SetDatumByPath(luaL_checkstring(L,2),var);
}else if(type == "nil")
{
VARIANT var;
var.vt = VT_NULL;
cmessage_arg(L,"mesage_SetPathValue")->SetDatumByPath(luaL_checkstring(L,2),var);
}else
{
throw_L_error(L, "Invalid type of value");
}
return 0;
}
示例4: strURL
HRESULT CHtmlCtrl::Navigate(LPCTSTR lpszURL,
DWORD dwFlags /*= 0*/,
LPCTSTR lpszTargetFrameName /*= NULL*/,
LPCTSTR lpszHeaders /*= NULL*/,
LPVOID lpvPostData /*= NULL*/,
DWORD dwPostDataLen /*= 0*/)
{
CString strURL(lpszURL);
BSTR bstrURL = strURL.AllocSysString();
COleSafeArray vPostData;
if (lpvPostData != NULL)
{
if (dwPostDataLen == 0)
dwPostDataLen = lstrlen((LPCTSTR) lpvPostData);
vPostData.CreateOneDim(VT_UI1, dwPostDataLen, lpvPostData);
}
return m_pBrowser->Navigate(bstrURL,
COleVariant((long) dwFlags, VT_I4),
COleVariant(lpszTargetFrameName, VT_BSTR),
vPostData,
COleVariant(lpszHeaders, VT_BSTR));
}
示例5: spDoc
void CDownloads_Opinions_WBEvents::RetrieveLinkToUsText(IDispatch *pdDoc)
{
IHTMLDocument2Ptr spDoc (pdDoc);
ASSERT (spDoc != NULL);
IHTMLElementCollectionPtr spelForms;
spDoc->get_forms (&spelForms);
if (spelForms == NULL)
return;
long cForms = 0;
spelForms->get_length (&cForms);
for (long i = 0; i < cForms; i++)
{
IDispatchPtr spdel;
spelForms->item (COleVariant (i), COleVariant (i), &spdel);
ASSERT (spdel != NULL);
IHTMLFormElementPtr spForm (spdel);
ASSERT (spForm != NULL);
bool bFound;
CString str = GetFormInputElementText (spForm, "LINKTOUSTEXT", bFound);
if (bFound)
_App.View_SpreadHelpDialog_LinkToUsText (str);
str = GetFormInputElementText (spForm, "RADIOBUTTON1TEXT", bFound);
if (bFound)
_App.View_SpreadHelpDialog_RadioButton1Text (str);
str = GetFormInputElementText (spForm, "RADIOBUTTON2TEXT", bFound);
if (bFound)
_App.View_SpreadHelpDialog_RadioButton2Text (str);
}
}
示例6: COleVariant
void IllusionExcelFile::FreezePanes(const TCHAR* cell){
CRange range = excel_work_sheet_.get_Range(COleVariant(cell), COleVariant(cell));
range.Select();
CWindow0 mwin = excel_application_.get_ActiveWindow();
mwin.put_FreezePanes(1);
range.ReleaseDispatch();
}
示例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: new_value
void CExcelFile::SetCellInt(long irow, long icolumn,int new_int)
{
COleVariant new_value((long)new_int);
CRange start_range = excel_work_sheet_.get_Range(COleVariant(_T("A1")),covOptional);
CRange write_range = start_range.get_Offset(COleVariant((long)irow -1),COleVariant((long)icolumn -1) );
write_range.put_Value2(new_value);
start_range.ReleaseDispatch();
write_range.ReleaseDispatch();
}
示例9: new_value
void IllusionExcelFile::SetCelltime(long irow, long icolumn, time_t new_time)
{
COleVariant new_value((COleDateTime)new_time);
CRange start_range = excel_work_sheet_.get_Range(COleVariant("A1"), covOptional);
CRange write_range = start_range.get_Offset(COleVariant((long)irow - 1), COleVariant((long)icolumn - 1));
write_range.put_Value2(new_value);
start_range.ReleaseDispatch();
write_range.ReleaseDispatch();
}
示例10: varBMark
BOOL CmyWord::Goto( const CString& strBMark )
{
COleVariant varBMark(strBMark); //设置变量
Bookmarks bookmarks = m_wdDoc.GetBookmarks();
if(!bookmarks.Exists((LPCTSTR)strBMark))
{
return FALSE;
}
m_wdSel.GoTo(COleVariant(short(1),VT_BOOL),COleVariant((short)0),COleVariant((short)0),varBMark);
return TRUE;
}
示例11: IsCellInt
//检查一个CELL是否是数值
BOOL CExcelFile::IsCellInt(long irow, long icolumn)
{
CRange range;
range.AttachDispatch(excel_current_range_.get_Item (COleVariant((long)irow),COleVariant((long)icolumn)).pdispVal, true);
COleVariant vResult =range.get_Value2();
//好像一般都是VT_R8
if(vResult.vt == VT_INT || vResult.vt == VT_R8)
{
return TRUE;
}
return FALSE;
}
示例12: varBMark_del
void CmyWord::UpdateField(CString strBMark)
{
COleVariant varBMark_del(strBMark); //设置变量
Bookmarks bookmarks = m_wdDoc.GetBookmarks();
if(!bookmarks.Exists((LPCTSTR)strBMark))
{
return;
}
m_wdSel.GoTo(COleVariant(short(1),VT_BOOL),COleVariant((short)0),COleVariant((short)0),varBMark_del);
Fields fields = Fields(m_wdSel.GetFields());
fields.Update();
bookmarks.ReleaseDispatch();
}
示例13: ASSERT
void CHtmlView::Navigate2(LPITEMIDLIST pIDL, DWORD dwFlags /* = 0 */,
LPCTSTR lpszTargetFrameName /* = NULL */)
{
ASSERT(m_pBrowserApp != NULL);
COleVariant vPIDL(pIDL);
COleVariant empty;
m_pBrowserApp->Navigate2(vPIDL,
COleVariant((long) dwFlags, VT_I4),
COleVariant(lpszTargetFrameName, VT_BSTR),
empty, empty);
}
示例14: AfxMessageBox
void CEx24dView::OnClockoleLoad()
{
if(!m_clock.CreateDispatch("Ex24c.Document")) {
AfxMessageBox("Ex24c.Document component not found");
return;
}
m_clock.SetFigure(0, COleVariant("XII"));
m_clock.SetFigure(1, COleVariant("III"));
m_clock.SetFigure(2, COleVariant("VI"));
m_clock.SetFigure(3, COleVariant("IX"));
OnClockoleRefreshtime();
m_clock.ShowWin();
}
示例15: DeleteRow
//每次删除完一行,原来的第二行就变为了现在的第一行
void IllusionExcelFile::DeleteRow(int iRow)
{
typedef enum XlDeleteShiftDirection
{
xlShiftToLeft = -4159,
xlShiftUp = -4162
};
excel_current_range_.AttachDispatch(excel_work_sheet_.get_Cells());
excel_current_range_.AttachDispatch(excel_current_range_.get_Item(COleVariant((long)iRow),covOptional).pdispVal);
excel_current_range_.AttachDispatch(excel_current_range_.get_EntireRow());
excel_current_range_.Delete(COleVariant((short)xlShiftUp));//原来的第二行就变为了现在的第一行
excel_current_range_.AttachDispatch(excel_work_sheet_.get_Cells());
}