qt集成dsoframer.ocx打开office办公软件
最近一段时间真是事情太多了,前不久项目中一个嵌入office软件的问题,由于没有时间研究,且项目的需求是浏览word文档,偷了一个懒,把word文档转换成pdf文档,然后嵌入libcef浏览器给打开了
现在回过头来,重新研究了这方面的直接办法,在网上查了多方面的资料,终于决定要使用ocx这个方案来完成此项功能,可限于资源问题,ocx方面的资料 没怎么接触过,所以就盲目的在晚上看别人的东西,不过皇天不负有心人,最终还是让我成功的搞定了这个问题,然后觉着,这个ocx也不过如此么,总的来说说 还是比较简单
我当前机器环境:windwos7 64位 dsoframer 1.3 qt5.5.1 vs2013
下边我说下我自己的步骤:
1、下载dsoframer.ocx,然后使用命令注册regsvr32.exe dsoframer.ocx
2、运行regedit.exe 在HKEY_LOCAL_MACHINE目录下搜索dsoframer,获取CLSID的值,这个是用作ocx的唯一标示,如果没有搜索到,可以下载其他的dsoframer,重新注册,或者给我留言
3、接下来直接上代码
QAxWidget * _Word = new QAxWidget(this);
_Word->setControl("{00460182-9E5E-11d5-B7C8-B8269041DD57}");
_Word->setProperty("Visible", true);
QString filePath = QFileDialog::getOpenFileName(, "Open doc file", QString(), "*.doc");
if (filePath.isEmpty())
return;
_Word->dynamicCall("Open(string)", filePath);
_Word->dynamicCall("SetCaption(string)", "ocx test");
_Word->dynamicCall("SetMenuAccelerators(bool)", false);
_Word->dynamicCall("SetMenubar(bool)", false);
QGridLayout * ply = new QGridLayout(this);
ply->addWidget(_Word, , , , );
ply->setContentsMargins(, , , );
ui.widget->setLayout(ply);
效果图如下:
dsoframer的相关接口,不过常用的也就那么几个
BeforeDocumentClosed(IDispatch*,bool&) Document,Cancel
BeforeDocumentSaved(IDispatch*,QString,bool&) Document,Location,Cancel
OnActivationChange(bool) fGoingActive
OnDocumentClosed()
OnDocumentOpened(QString,IDispatch*) File,Document
OnFileCommand(dsoFileCommandType,bool&) Item,Cancel
OnPrintPreviewExit()
OnSaveCompleted(IDispatch*,QString,QString) Document,DocName,FullFileLocation
exception(int,QString,QString,QString) code,source,disc,help
propertyChanged(QString) name
signal(QString,int,void*) name,argc,argv
Activate()
Close()
CreateNew(QString) ProgIdOrTemplate
EnableFileCommand(dsoFileCommandType) Item bool
ExecOleCommand(int) OLECMDID
ExecOleCommand(int,QVariant) OLECMDID,Options
ExecOleCommand(int,QVariant,QVariant&) OLECMDID,Options,vInParam
ExecOleCommand(int,QVariant,QVariant&,QVariant&) OLECMDID,Options,vInParam,vInOutParam
GetDataObjectContent(QVariant) ClipFormatNameOrNumber QVariant
Open(QVariant) Document
Open(QVariant,QVariant) Document,ReadOnly
Open(QVariant,QVariant,QVariant) Document,ReadOnly,ProgId
Open(QVariant,QVariant,QVariant,QVariant)Document,ReadOnly,ProgId,WebUsername
Open(QVariant,QVariant,QVariant,QVariant,QVariant) Document,ReadOnly,ProgId,WebUsername,WebPassword
PrintOut()
PrintOut(QVariant) PromptUser
PrintOut(QVariant,QVariant) PromptUser,PrinterName
PrintOut(QVariant,QVariant,QVariant) PromptUser,PrinterName,Copies
PrintOut(QVariant,QVariant,QVariant,QVariant)
PromptUser,PrinterName,Copies,FromPage
PrintOut(QVariant,QVariant,QVariant,QVariant,QVariant) PromptUser,PrinterName,Copies,FromPage,ToPage
PrintOut(QVariant,QVariant,QVariant,QVariant,QVariant,QVariant) PromptUser,PrinterName,Copies,FromPage,ToPage,OutputFile
PrintPreview()
PrintPreviewExit()
Save()
Save(QVariant) SaveAsDocument
Save(QVariant,QVariant) SaveAsDocument,OverwriteExisting
Save(QVariant,QVariant,QVariant)
SaveAsDocument,OverwriteExisting,WebUsername
Save(QVariant,QVariant,QVariant,QVariant) SaveAsDocument,OverwriteExisting,WebUsername,WebPassword
SetActivationPolicy(dsoActivationPolicy) ActivationPolicy
SetBackColor(QColor) BackColor
SetBorderColor(QColor) BorderColor
SetBorderStyle(dsoBorderStyle) BorderStyle
SetCaption(QString) Caption
SetDataObjectContent(QVariant,QVariant) ClipFormatNameOrNumber,DataByteArray
SetEnableFileCommand(dsoFileCommandType,bool) Item,rhs
SetEventsEnabled(bool) EventsEnabled
SetForeColor(QColor) ForeColor
SetFrameHookPolicy(dsoFrameHookPolicy) FrameHookPolicy
SetHostName(QString)HostName
SetLockServer(bool) LockServer
SetMenuAccelerators(bool) MenuAccelerators
SetMenubar(bool) Menubar SetModalState(bool) ModalState
SetTitlebar(bool) Titlebar
SetTitlebarColor(QColor) TitlebarColor
SetTitlebarTextColor(QColor) TitlebarTextColor
SetToolbars(bool) Toolbars
ShowDialog(dsoShowDialogType) DlgType
_PrintOutOld()
_PrintOutOld(QVariant) PromptToSelectPrinter
如果想看哪种方法调用失败或者是异常,请参考C++ gui程序附加dos输出窗口
注:需要完整事例的可以给我留言
![]() |
![]() |
很重要--转载声明
- 本站文章无特别说明,皆为原创,版权所有,转载时请用链接的方式,给出原文出处。同时写上原作者:朝十晚八 or Twowords
- 如要转载,请原文转载,如在转载时修改本文,请事先告知,谢绝在转载时通过修改本文达到有利于转载者的目的。
qt集成dsoframer.ocx打开office办公软件的更多相关文章
- Office办公软件Excel使用整理
Office办公软件Excel使用整理 Excel默认打印预览于当前连接的打印机的纸张大小保持一致. Excel sheet不见了怎么办 -------------- 设置Excel第二页打印开始的位 ...
- 各版本Office办公软件下载
各版本Office办公软件下载:http://pan.baidu.com/share/home?uk=1174874628
- Office办公软件(Excel PPT Word)使用整理
Office办公软件(Excel PPT Word)使用整理.. -------------- Excel默认打印预览于当前连接的打印机的纸张大小保持一致. Excel sheet不见了怎么办 --- ...
- Linux常用Office办公软件
1.WPS Office是由金山软件股份有限公司自主研发的一款办公软件套件,可以实现办公最常用的文字.表格.演示等多种功能.免费提供海量的在线存储空间及文档模板.支持阅读和输出PDF文件.全面兼容Mi ...
- 【项目经验】macpro上安装office办公软件并破解
链接: https://pan.baidu.com/s/1i5hyKO9 密码: 7zjf 如果本机原有office,先卸载 双击pkg文件安装office for Mac 2016 安装完不要做打开 ...
- qt: 系统默认程序打开文件或者软件;
Qt提供了QDesktopServices类, 可以利用openUrl函数调用默认程序打开文件: 源码参考: #ifdef Q_OS_WIN32 m_szHelpDoc = QString(" ...
- Office办公软件各版本下载(一键安装)
史上最快最全的Office套件,含Word.PPT.Excel.Access.Outlook完整组件(微软官方版本). 推荐安装Office2010版本!一键完成清理.安装Office.自动激活. 图 ...
- 自己的系统重装之后,怎么去重新的装官方的office办公软件,详细教程
1 访问官网地址--微软,并通过自己的微软账号进行登录,转到下面的界面 2 点击上图的菜单栏的offce菜单项,跳转到下图 3 点击 菜单栏的产品 之后选择 查看office的全部的历史 ...
- 全套Office办公软件WORD/PPT/EXCEL视频教程 每日更新中
详情见Processon分享链接:https://www.processon.com/view/link/5b3f40abe4b09a67415e2bfc
随机推荐
- unity一个按钮实现开和关
using System.Collections; using System.Collections.Generic; using UnityEngine; public class ButtonCl ...
- 彻底解决eclipse中tomcat启动速度缓慢的问题
问题: Tomcat启动提示At least one JAR was scanned for TLDs yet contained no TLDs tomcat启动速度总是很慢,检查后发现tomcat ...
- python: 列表的方法
操作 函数 使用方法 备注 索引 index in: example.index(‘creative’) --- 1 in:example[1,] --- [’creative’, [’京东’,996 ...
- Ubuntu 18.04 系统配置 NPM环境和mysql数据库问题解决
Node.js 是一个基于 Chrome V8 引擎的 JavaScript 运行环境. Node.js 使用了一个事件驱动.非阻塞式 I/O 的模型,使其轻量又高效. 今天我就为大家 使用 Ubun ...
- 【Linux】如何在Linux上安装使用SSH
SSH是什么? Secure Shell 安全外壳协议 建立在应用层基础上的安全协议 可靠,专为远程登录会话和其他网络服务提供安全性的协议 有效防止远程管理过程中的信息泄露问题 SSH客户端适用于多种 ...
- <算法图解>读书笔记:第1章 算法简介
阅读书籍:[美]Aditya Bhargava◎著 袁国忠◎译.人民邮电出版社.<算法图解> 第1章 算法简介 1.2 二分查找 一般而言,对于包含n个元素的列表,用二分查找最多需要\(l ...
- CF.802C.Heidi and Library (hard) (费用流zkw)
题目链接 复习了下餐巾计划问题.全忘了=-= 首先这是一道网络流.然后本题有\(n\)种建图方法,以及\(smy\) dalao还有单纯形做法. 先假设所有物品都是买入的.那么对于每一天,拆成两个点\ ...
- win10自带的防火墙Windows Defender
Windows Defender防火墙(别名:windows守卫者)是微软公司自主研发的一款基于windows自身保护的一款系统. Windows Defender可以对系统进行实时监控,对于Wind ...
- c#几种随机数组和数组乱序
相关资料MSDN:RNGCryptoServiceProvider Random Guid private static RNGCryptoServiceProvider rngCsp = n ...
- GeoHash(Java实现)
package com.koubei.collect_script.demo; import java.util.ArrayList; import java.util.Arrays; import ...

