Using win32 Com/ActiveX (Internet Explorer) with SWT [message #452603] |
Wed, 23 March 2005 02:53 |
Franck Mising name 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 #452753 is a reply to message #452603] |
Thu, 24 March 2005 13:23 |
Veronika Irvine 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,
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.02737 seconds