在CHtmlView中获取所选文件 [英] Get selected files in CHtmlView

查看:61
本文介绍了在CHtmlView中获取所选文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!



我是一个使用CHtmlView作为查看我的应用程序中的文件夹和文件的基础。



但是,我需要能够在我的应用程序中知道当用户采取某种操作时按下f.ex.按钮时在视图中选择了哪些文件和文件夹。我广泛搜索了这个,但我无法让它工作。我假设我必须使用IDispatch接口,但每当我调用QueryInformation时,我总是得到接口不支持错误,除非我使用IID_IDispatch而不是IID_IHTMLDocument2,但这似乎也不起作用。



例如:



IDispatch * pDisp = this-> GetHtmlDocument();



HRESULT hr = pIHtmlDisp-> QueryInterface(IID_IHTMLDocument2,(void **)&pIHTMLDocument2);



hr返回E_NOINTERFACE



因为我们在文件夹视图中对我有意义我有使用IID_IHTMLDocument2的其他变体,但我一直无法提出解决方案。



希望有人可以提供帮助。



亲切的问候



Dark

解决方案

IDispatch * pDisp = this- > GetHtmlDocument();

//使用HTML的界面

HRESULT hr = pDisp-> QueryInterface(IID_IHTMLDocument2,(void **)& pIHTMLDocument2) ;



另请参阅 IWebBrowser2


回复的Thx,但这正是我正在做的事情。

当我尝试你发布的代码时,HRESULT返回E_NOINTERFACE。

通过使用Navigate2(CString或PIDL)到文件夹创建视图,似乎没有基础HTMLDocume nt2在视图中。



亲切的问候,



黑暗


< blockquote>解决方案在于它不是您导航到文件夹视图时获得的HTML文档。



来自其他论坛:



当您查看文件夹和文件时,显示的文档不是HTML文档。它是IShellBrowser或IShellView - 尝试查询那些(如果你得到IShellBrowser,你可以使用QueryActiveShellView获取视图)。



当你得到视图时,查询它IFolderView和调用项目(SVGIO_SELECTION)



Igor Tandetnik


Hi everyone!

Im a using CHtmlView as the base for viewing folders and files in my application.

However, I need to be able to know in my application what files and folders are selected in the view when the user takes a certain action (pressing a button f.ex.). I have googled this extensively but I am unable to get it to work. I assume that I have to use the IDispatch interface, but whenever I call QueryInformation I always get "Interface not supported error", unless I use IID_IDispatch instead of IID_IHTMLDocument2, but this doesn't seem to work either.

example:

IDispatch *pDisp = this->GetHtmlDocument();

HRESULT hr = pIHtmlDisp->QueryInterface(IID_IHTMLDocument2, (void**)&pIHTMLDocument2);

hr returns E_NOINTERFACE

Since we are in the folder view it makes sense to me that I have to use some other variation that the IID_IHTMLDocument2, but I have been unable to come up with a solution.

Hope someone can help.

Kind regards

Dark

解决方案

IDispatch *pDisp = this->GetHtmlDocument();
//use the interface of the HTML
HRESULT hr = pDisp->QueryInterface(IID_IHTMLDocument2, (void**)&pIHTMLDocument2);

Take also a look on IWebBrowser2


Thx for the reply but this is exactly what I was doing.
HRESULT returns E_NOINTERFACE when I try the code you posted.
The view is created by using Navigate2(CString or PIDL) to a folder, and it seems there is no underlying HTMLDocument2 in the view.

Kind regards,

Dark


The solution lies in that its not a HTML document you get when you Navigate to a folderview.

From other forum:

"When you view folders and files, the document displayed is not an HTML document. It's either IShellBrowser or IShellView - try querying for those (if you get IShellBrowser, you can obtain the view with QueryActiveShellView).

When you get the view, query it for IFolderView and call Items(SVGIO_SELECTION)

Igor Tandetnik"


这篇关于在CHtmlView中获取所选文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆