Click here to Skip to main content
15,892,575 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Posted

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

Take also a look on IWebBrowser2
 
Share this answer
 
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
 
Share this answer
 
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"
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900