Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Using win32 Com/ActiveX (Internet Explorer) with SWT
Using win32 Com/ActiveX (Internet Explorer) with SWT [message #452603] Wed, 23 March 2005 02:53 Go to next message
Franck Mising name is currently offline Franck Mising nameFriend
Messages: 92
Registered: July 2009
Location: France
Member
Hi,
I try to use Internet Explorer inside a SWT application. It's easy and it
works well for simple things.
But I can't access specific interfaces of the main component.
Is there someone having some examples or advices ?

More concretely, I create a component representing Internet Explorer as
follows :

final OleControlSite controlSite = new OleControlSite(frame,
SWT.NONE, "Shell.Explorer.2");
final OleAutomation webBrowser = new OleAutomation(controlSite);

Then, I would like to access a method SetUIHandler in an interface of this
component, with name ICustomDoc.
I've tried different ways, even the following, but none of them work.

public static final GUID IIDICustomDoc =
IIDFromString("{3050F3F0-98B5-11CF-BB82-00AA00BDCE0B}"); //$NON-NLS-1$
IDispatch objDispatch = new IDispatch(webBrowser.getAddress());
int[] ppvObject = new int[1];
//int result = objDispatch.QueryInterface(IIDIHTMLWindow2,
ppvObject);
int result = objDispatch.QueryInterface(IIDICustomDoc, ppvObject);
if (result == COM.S_OK)
System.out.print("OK OK OK - Interface found!");
else
System.out.print("NO NO NO - Interface not found!");


With C++, it could be implemented as follows:
================================
IHTMLDocument2* pDoc = ...;
ICustomDoc* pCustom = 0;
hr = pDoc->QueryInterface(IID_ICustomDoc, (void**)&pCustom);
if (SUCCEEDED(hr)) {
pCustom->SetUIHandler(pMyDocHostUIHandler);
pCustom->Release();
}

Or with C#, an implementation could be :
================================
ICustomDoc cDoc = (ICustomDoc)this.WebBrowser.Document;
cDoc.SetUIHandler((IDocHostUIHandler)this);

IDocHostUIHandler has to be implemented by your application. You can then
use ICustomDoc::SetUIHandler to tell MSHTML that you have this interface.


The interface :
==========
ICustomDoc = interface(IUnknown)
['{3050f3f0-98b5-11cf-bb82-00aa00bdce0b}']
function SetUIHandler(const pUIHandler: IDocHostUIHandler): HResult;
stdcall;


Many thanks in advance,
Re: Using win32 Com/ActiveX (Internet Explorer) with SWT [message #452720 is a reply to message #452603] Wed, 23 March 2005 14:34 Go to previous messageGo to next message
Christophe Cornu is currently offline Christophe CornuFriend
Messages: 304
Registered: July 2009
Senior Member
Hi Frank,

The SWT Browser widget embeds IE on Windows. You can check its
implementation for an example on how to implement IDocHostUIHandler. It's
done in the WebSite class here (search for iDocHostUIHandler and methods
from that interface: GetHostInfo etc.).

http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt/Ecl ipse%20SWT%20Browser/win32/org/eclipse/swt/browser/WebSite.j ava?rev=HEAD&content-type=text/vnd.viewcvs-markup

Chris
Re: Using win32 Com/ActiveX (Internet Explorer) with SWT [message #452753 is a reply to message #452603] Thu, 24 March 2005 13:23 Go to previous message
Veronika Irvine is currently offline Veronika IrvineFriend
Messages: 1272
Registered: July 2009
Senior Member
The SWT ActiveX support uses IDispatch interfaces to access behaviour in
custom interfaces.

Please see the following article:

http://www.eclipse.org/articles/Article-ActiveX%20Support%20 in%20SWT/ActiveX%20Support%20in%20SWT.html

and the following code examples:

http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.sni ppets/src/org/eclipse/swt/snippets/Snippet123.java?rev=HEAD& amp;content-type=text/vnd.viewcvs-markup
http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.sni ppets/src/org/eclipse/swt/snippets/Snippet186.java?rev=HEAD& amp;content-type=text/vnd.viewcvs-markup
http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.sni ppets/src/org/eclipse/swt/snippets/Snippet187.java?rev=HEAD& amp;content-type=text/vnd.viewcvs-markup

"Franck" <soux2@hotmail.com> wrote in message
news:d1qqg3$mt2$1@news.eclipse.org...
> Hi,
> I try to use Internet Explorer inside a SWT application. It's easy and it
> works well for simple things.
> But I can't access specific interfaces of the main component.
> Is there someone having some examples or advices ?
>
> More concretely, I create a component representing Internet Explorer as
> follows :
>
> final OleControlSite controlSite = new OleControlSite(frame,
> SWT.NONE, "Shell.Explorer.2");
> final OleAutomation webBrowser = new OleAutomation(controlSite);
>
> Then, I would like to access a method SetUIHandler in an interface of this
> component, with name ICustomDoc.
> I've tried different ways, even the following, but none of them work.
>
> public static final GUID IIDICustomDoc =
> IIDFromString("{3050F3F0-98B5-11CF-BB82-00AA00BDCE0B}"); //$NON-NLS-1$
> IDispatch objDispatch = new IDispatch(webBrowser.getAddress());
> int[] ppvObject = new int[1];
> //int result = objDispatch.QueryInterface(IIDIHTMLWindow2,
> ppvObject);
> int result = objDispatch.QueryInterface(IIDICustomDoc, ppvObject);
> if (result == COM.S_OK)
> System.out.print("OK OK OK - Interface found!");
> else
> System.out.print("NO NO NO - Interface not found!");
>
>
> With C++, it could be implemented as follows:
> ================================
> IHTMLDocument2* pDoc = ...;
> ICustomDoc* pCustom = 0;
> hr = pDoc->QueryInterface(IID_ICustomDoc, (void**)&pCustom);
> if (SUCCEEDED(hr)) {
> pCustom->SetUIHandler(pMyDocHostUIHandler);
> pCustom->Release();
> }
>
> Or with C#, an implementation could be :
> ================================
> ICustomDoc cDoc = (ICustomDoc)this.WebBrowser.Document;
> cDoc.SetUIHandler((IDocHostUIHandler)this);
>
> IDocHostUIHandler has to be implemented by your application. You can then
> use ICustomDoc::SetUIHandler to tell MSHTML that you have this interface.
>
>
> The interface :
> ==========
> ICustomDoc = interface(IUnknown)
> ['{3050f3f0-98b5-11cf-bb82-00aa00bdce0b}']
> function SetUIHandler(const pUIHandler: IDocHostUIHandler): HResult;
> stdcall;
>
>
> Many thanks in advance,
>
>
Previous Topic:Second header column
Next Topic:Display.asyncExec and UI queue
Goto Forum:
  


Current Time: Thu Apr 25 22:01:45 GMT 2024

Powered by FUDForum. Page generated in 0.02831 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top