Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Help: implementing IDocHostUIHandler and GetExternal method
Help: implementing IDocHostUIHandler and GetExternal method [message #450393] |
Fri, 11 February 2005 14:41 |
Eclipse User |
|
|
|
Originally posted by: NoSpam.NoSpam.Com
Below is a code snippet in which I tried to implement IDocHostUIHandler.
Through implementing this interface it should be possible to call external
code from within JavaScript that run in the WebBrowser ActiveX component (by
calling window.external.doSomething). IDocHostUIHandlerImpl has a method
GetExternal. This method should return an IDispatch interface. I created a
sample IDispatch implementation but when I return my app crashes...... Any
ideas what could be wrong? Any help is welcome.
class IDocHostUIHandlerImpl {
private COMObject iDocHostUIHandler;
private int refCount = 0;
public IDocHostUIHandlerImpl() {
createCOMInterfaces();
}
public int getAddress() {
int address = iDocHostUIHandler.getAddress();
return address;
}
private void createCOMInterfaces() {
iDocHostUIHandler = new COMObject(new int[]{2, 0, 0, 4, 1, 5, 0, 0, 1, 1, 1,
3, 3, 2, 2, 1, 3, 2}){
public int method0(int[] args) {return QueryInterface(args[0], args[1]);}
public int method1(int[] args) {return AddRef();}
public int method2(int[] args) {return Release();}
// method3 (not implemented) - ShowContextMenu
// method4 (not implemented) - GetHostInfo
// method5 (not implemented) - ShowUI
// method6 (not implemented) - HideUI
// method7 (not implemented) - UpdateUI
// method8 (not implemented) - EnableModeless
// method9 (not implemented) - OnDocWindowActivate
// method10 (not implemented) - OnFrameWindowActivate
// method11 (not implemented) - ResizeBorder
// method12 (not implemented) - TranslateAccelerator
// method13 (not implemented) - GetOptionKeyPath
// method14 (not implemented) - GetDropTarget
public int method15(int[] args) { return GetExternal(args[0]); }
// method16 (not implemented) - TranslateUrl
// method17 (not implemented) - FilterDataObject
};
}
private int GetExternal(int ppDispatch) {
Logger.log(LoggerSelectors.WEB, (short) 2, "GetExternal!");
EventDispatch ed = new EventDispatch(0);
COM.MoveMemory(ppDispatch, new int[] {ed.getAddress()}, 4);
return COM.S_OK;
}
|
|
|
Re: implementing IDocHostUIHandler and GetExternal method [message #450425 is a reply to message #450393] |
Fri, 11 February 2005 18:40 |
Eclipse User |
|
|
|
Originally posted by: NoSpam.NoSpam.Com
I think I solved my problem, changing the implementation for GetExternal
from:
private int GetExternal(int ppDispatch) {
EventDispatch ed = new EventDispatch(0);
COM.MoveMemory(ppDispatch, new int[] {ed.getAddress()}, 4);
return COM.S_OK;
}
to:
private int GetExternal(int ppDispatch) {
EventDispatch ed = new EventDispatch(0);
IDispatch iDispatch = new IDispatch(ed.getbAddress());
iDispatch.AddRef();
COM.MoveMemory(ppDispatch, new int[] {iDispatch.getAddress()}, 4);
return COM.S_OK;
}
Don't understand entirely why this works, any ideas?
Gr,
Frank
"FrankVanMoorsel" <NoSpam@NoSpam.Com> wrote in message
news:cuig6q$8dn$1@www.eclipse.org...
> Below is a code snippet in which I tried to implement IDocHostUIHandler.
> Through implementing this interface it should be possible to call external
> code from within JavaScript that run in the WebBrowser ActiveX component
> (by calling window.external.doSomething). IDocHostUIHandlerImpl has a
> method GetExternal. This method should return an IDispatch interface. I
> created a sample IDispatch implementation but when I return my app
> crashes...... Any ideas what could be wrong? Any help is welcome.
>
>
>
>
>
> class IDocHostUIHandlerImpl {
>
>
> private COMObject iDocHostUIHandler;
>
> private int refCount = 0;
>
> public IDocHostUIHandlerImpl() {
>
> createCOMInterfaces();
>
> }
>
> public int getAddress() {
>
> int address = iDocHostUIHandler.getAddress();
>
> return address;
>
> }
>
> private void createCOMInterfaces() {
>
> iDocHostUIHandler = new COMObject(new int[]{2, 0, 0, 4, 1, 5, 0, 0, 1, 1,
> 1, 3, 3, 2, 2, 1, 3, 2}){
>
> public int method0(int[] args) {return QueryInterface(args[0], args[1]);}
>
> public int method1(int[] args) {return AddRef();}
>
> public int method2(int[] args) {return Release();}
>
> // method3 (not implemented) - ShowContextMenu
>
> // method4 (not implemented) - GetHostInfo
>
> // method5 (not implemented) - ShowUI
>
> // method6 (not implemented) - HideUI
>
> // method7 (not implemented) - UpdateUI
>
> // method8 (not implemented) - EnableModeless
>
> // method9 (not implemented) - OnDocWindowActivate
>
> // method10 (not implemented) - OnFrameWindowActivate
>
> // method11 (not implemented) - ResizeBorder
>
> // method12 (not implemented) - TranslateAccelerator
>
> // method13 (not implemented) - GetOptionKeyPath
>
> // method14 (not implemented) - GetDropTarget
>
> public int method15(int[] args) { return GetExternal(args[0]); }
>
> // method16 (not implemented) - TranslateUrl
>
> // method17 (not implemented) - FilterDataObject
>
> };
>
> }
>
> private int GetExternal(int ppDispatch) {
>
> Logger.log(LoggerSelectors.WEB, (short) 2, "GetExternal!");
>
>
> EventDispatch ed = new EventDispatch(0);
>
> COM.MoveMemory(ppDispatch, new int[] {ed.getAddress()}, 4);
>
>
> return COM.S_OK;
>
> }
>
>
|
|
|
Goto Forum:
Current Time: Fri Mar 29 12:26:05 GMT 2024
Powered by FUDForum. Page generated in 0.04051 seconds
|