WizKnowledge COM对象之IWizExplorerWindow
- 文件:WizExplorer.exe
object,
uuid(B15879A3-8647-4d6f-84D8-3A24709EC962),
dual,
nonextensible,
helpstring("IWizExplorerWindow Interface"),
pointer_default(unique)
]
interface IWizExplorerWindow : IDispatch{
//获得/设置当前的视图,可能的值:Folders, Tags, Styles。
[propget, id(1), helpstring("property CurrentCatalogView")] HRESULT CurrentCatalogView([out, retval] BSTR* pVal);
[propput, id(1), helpstring("property CurrentCatalogView")] HRESULT CurrentCatalogView([in] BSTR newVal);
//获得文件夹ActiveX控件。类型为IWizFolderTreeCtrl
[propget, id(2), helpstring("property FoldersCtrl")] HRESULT FoldersCtrl([out, retval] IDispatch** pVal);
//获得标签ActiveX控件。类型为IWizTagTreeCtrl
[propget, id(3), helpstring("property TagsCtrl")] HRESULT TagsCtrl([out, retval] IDispatch** pVal);
//获得样式ActiveX控件,类型为IWizStyleListBox
[propget, id(4), helpstring("property StylesCtrl")] HRESULT StylesCtrl([out, retval] IDispatch** pVal);
//获得文档列表ActiveX控件,类型为IWizDocumentListCtrl
[propget, id(5), helpstring("property DocumentsCtrl")] HRESULT DocumentsCtrl([out, retval] IDispatch** pVal);
//获得主窗口的窗口句柄
[propget, id(6), helpstring("property HWND")] HRESULT HWND([out, retval] OLE_HANDLE* pVal);
//获得当前正在阅读的文档对象,类型为IWizDocument
[propget, id(7), helpstring("property CurrentDocument")] HRESULT CurrentDocument([out, retval] IDispatch** pVal);
//获得当前正在阅读的文档的Html文档对象,类型为IHTMLDocument2,就是Html文件脚本里面的document对象。
[propget, id(8), helpstring("property CurrentDocumentHtmlDocument")] HRESULT CurrentDocumentHtmlDocument([out, retval] IDispatch** pVal);
//获得当前正在阅读的文档的附件ActiveX控件,IWizDocumentAttachmentListCtrl
[propget, id(9), helpstring("property CurrentDocumentAttachmentCtrl")] HRESULT CurrentDocumentAttachmentCtrl([out, retval] IDispatch** pVal);
//显示一个Html对话框,bstrURL:Html文件的URL或者Html文件名;nWidth:对话框宽度;nHeight:对话框高度;bstrExtOptions:扩展选项,暂不支持。返回指为关闭Html对话框的代码。
[id(10), helpstring("method ShowHtmlDialog")] HRESULT ShowHtmlDialog([in] BSTR bstrTitle, [in] BSTR bstrURL, [in] LONG nWidth, [in] LONG nHeight, [in] BSTR bstrExtOptions, [out, retval] LONG* pnRet);
//关闭Html对话框。pHtmlDocumentDisp为Html文件脚本里面的document对象;nCloseCommand:关闭代码,会通过ShowHtmlDialog函数返回给调用者。
[id(11), helpstring("method CloseHtmlDialog")] HRESULT CloseHtmlDialog([in] IDispatch* pHtmlDocumentDisp, [in] LONG nCloseCommand);
//在WizExplorer里面显示一个文档。pDocumentDisp:IWizDocument对象;vbOpenInNewTab:是否在新窗(标签)口打开。
[id(12), helpstring("method ViewDocument")] HRESULT ViewDocument([in] IDispatch* pDocumentDisp, [in] VARIANT_BOOL vbOpenInNewTab);
//显示一个Html文件或者一个html网页。bstrURL:网页的URL或者html文件名;vbOpenInNewTab:是否在新窗(标签)口打开。
[id(13), helpstring("method ViewHtml")] HRESULT ViewHtml([in] BSTR bstrURL, [in] VARIANT_BOOL vbOpenInNewTab);
//获得Html对话框窗口的句柄。pHtmlDocumentDisp为Html文件脚本里面的document对象。
[id(14), helpstring("method GetHtmlDialogHWND")] HRESULT GetHtmlDialogHWND([in] IDispatch* pHtmlDocumentDisp, [out,retval] OLE_HANDLE* phHWND);
};
例子:在Html对话框插件里面使用IWizExploerWindow.
将下面的内容保存成html文件,然后用IE打开,并且允许运行脚本和ActiveX控件,就可以看到效果。
<head>
<title>test html dialog</title>
</htad>
<body>
<a href=”JavaScript:CloseDialog(1);”>确定</a>
<a href=”JavaScript:CloseDialog(2);”>取消</a>
<hr>
<script language=”JavaScript”>
var app = new ActiveXObject(“WizExplorer.WizExplorerApp”); //创建IWizExploerApp
var current_document = app.Window.CurrentDocument; //当前文档
if (current_document != null)
{
document.write(“<div>当前文档:” + current_document.Title + “</div>”); //显示当前文档标题
}
document.write(“<div>当前视图:” + app.Window.CurrentCatalogView + “</div>”); //显示当前视图
function SwitchCatalog(name)
{
app.Window.CurrentCatalogView = name; //切换当前视图
}
</script>
<a href=’JavaScript:SwitchCatalog(“Folders”);’>切换到文件夹</a> <br />
<a href=’JavaScript:SwitchCatalog(“Tags”);’>切换到标签</a> <br />
<a href=’JavaScript:SwitchCatalog(“Styles”);’>切换到样式</a> <br />
<hr>
<div>文档列表</div>
<script language=”JavaScript”>
var document_list = app.Window.DocumentsCtrl; //获得文档列表
var documents = document_list.GetDocuments(); //获得文档列表中的文档
if (documents)
{
for (var i = 0; i < documents.Count; i++)
{
document.write(“<div>” + documents.Item(i).Title + “</div>”); //列出文档
}
}
function CloseDialog(command)
{
//app.Window.CloseHtmlDialog(document, command); //关闭对话框。用IE直接打开改html文件,这个命令无效。
}
</script>
</body>
</html>
最近评论