Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Failed to create Ole Client
Failed to create Ole Client [message #443128] Mon, 20 September 2004 03:24 Go to next message
hechengrong is currently offline hechengrongFriend
Messages: 5
Registered: July 2009
Junior Member
hello All:
I have a problem with OleClientSite. I want to use Word in applet by
OleClientSite. The first time I create an OleClientSite I have no problems,
but when I do it the second time I obtain the following exception:
org.eclipse.swt.SWTException: Failed to create Ole Client. result
= -2147418111.

These my code:

package ExcelApplet;

import java.applet.Applet;
import java.awt.Canvas;
import java.awt.GridLayout;
import org.eclipse.swt.awt.SWT_AWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.SWT;
import org.eclipse.swt.SWTException;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.ole.win32.OLE;
import org.eclipse.swt.ole.win32.OleAutomation;
import org.eclipse.swt.ole.win32.OleClientSite;
import org.eclipse.swt.ole.win32.OleFrame;
import org.eclipse.swt.ole.win32.Variant;

public class Excel extends Applet implements Runnable{
private Display display = null;
private OleClientSite site = null;
private OleAutomation auto = null;
private Thread swtThread = null;

public void init(){
if (swtThread == null)
swtThread = new Thread(this);
swtThread.start();
}

public void start(){
}

public void run(){
if (display != null) return;

this.setLayout(new GridLayout(1, 1));
Canvas awtParent = new Canvas();
this.add(awtParent);

display = new Display();
Shell swtParent = SWT_AWT.new_Shell(display, awtParent);

this.createContents(swtParent);

Point size = swtParent.computeSize (SWT.DEFAULT + awtParent.getWidth(),
SWT.DEFAULT+awtParent.getHeight());
awtParent.setSize(size.x + 2, size.y + 2);

validate();

while (!swtParent.isDisposed()) {
if (!display.readAndDispatch()) display.sleep ();
}
}

public void stop(){
if (swtThread != null){
swtThread.interrupt();
swtThread = null;
}
}

public void createContents(Shell shell){
shell.setLayout(new FillLayout());
createMenu(shell);

OleFrame frame = new OleFrame(shell, SWT.NONE);
try{
site = new OleClientSite(frame, SWT.NONE, "Word.Document");
auto = new OleAutomation(site);
}
catch (SWTException e){
String str = "Create OleClientSite Error" + "\n"
+ e.toString();
System.out.println(str);
System.exit(0);
}

showControl();
}

public void showControl(){
site.doVerb(OLE.OLEIVERB_SHOW);
}
}
Re: Failed to create Ole Client [message #443130 is a reply to message #443128] Mon, 20 September 2004 05:56 Go to previous messageGo to next message
hechengrong is currently offline hechengrongFriend
Messages: 5
Registered: July 2009
Junior Member
hechengrong wrote:
sorry, the exception is this: org.eclipse.swt.SWTEception: Failed to
create Ole Client. result = - -2147024882.

> hello All:
> I have a problem with OleClientSite. I want to use Word in applet by
> OleClientSite. The first time I create an OleClientSite I have no problems,
> but when I do it the second time I obtain the following exception:
> org.eclipse.swt.SWTException: Failed to create Ole Client. result
> = -2147418111.

> These my code:

> package ExcelApplet;

> import java.applet.Applet;
> import java.awt.Canvas;
> import java.awt.GridLayout;
> import org.eclipse.swt.awt.SWT_AWT;
> import org.eclipse.swt.widgets.Display;
> import org.eclipse.swt.widgets.Shell;
> import org.eclipse.swt.SWT;
> import org.eclipse.swt.SWTException;
> import org.eclipse.swt.graphics.Point;
> import org.eclipse.swt.layout.FillLayout;
> import org.eclipse.swt.ole.win32.OLE;
> import org.eclipse.swt.ole.win32.OleAutomation;
> import org.eclipse.swt.ole.win32.OleClientSite;
> import org.eclipse.swt.ole.win32.OleFrame;
> import org.eclipse.swt.ole.win32.Variant;

> public class Excel extends Applet implements Runnable{
> private Display display = null;
> private OleClientSite site = null;
> private OleAutomation auto = null;
> private Thread swtThread = null;

> public void init(){
> if (swtThread == null)
> swtThread = new Thread(this);
> swtThread.start();
> }

> public void start(){
> }

> public void run(){
> if (display != null) return;

> this.setLayout(new GridLayout(1, 1));
> Canvas awtParent = new Canvas();
> this.add(awtParent);

> display = new Display();
> Shell swtParent = SWT_AWT.new_Shell(display, awtParent);

> this.createContents(swtParent);

> Point size = swtParent.computeSize (SWT.DEFAULT + awtParent.getWidth(),
> SWT.DEFAULT+awtParent.getHeight());
> awtParent.setSize(size.x + 2, size.y + 2);

> validate();

> while (!swtParent.isDisposed()) {
> if (!display.readAndDispatch()) display.sleep ();
> }
> }

> public void stop(){
> if (swtThread != null){
> swtThread.interrupt();
> swtThread = null;
> }
> }

> public void createContents(Shell shell){
> shell.setLayout(new FillLayout());
> createMenu(shell);

> OleFrame frame = new OleFrame(shell, SWT.NONE);
> try{
> site = new OleClientSite(frame, SWT.NONE, "Word.Document");
> auto = new OleAutomation(site);
> }
> catch (SWTException e){
> String str = "Create OleClientSite Error" + "n"
> + e.toString();
> System.out.println(str);
> System.exit(0);
> }

> showControl();
> }

> public void showControl(){
> site.doVerb(OLE.OLEIVERB_SHOW);
> }
> }
Re: Failed to create Ole Client [message #443133 is a reply to message #443130] Mon, 20 September 2004 09:18 Go to previous message
Tiberiu Caprita is currently offline Tiberiu CapritaFriend
Messages: 68
Registered: July 2009
Member
Hi,
for errors you have to look in winerrors.h or in application (Word)
specific errors (look on msdn).

For your cases, the errors belong to winerrors.h:
-2147024882==0x8007000e
says E_OUTOFMEMORY
while
-2147418111 == 0x80010001
says RPC_E_CALL_REJECTED

Tiberiu
Previous Topic:Failed to create Ole Client
Next Topic:Scrolling tabitems
Goto Forum:
  


Current Time: Fri Apr 26 23:19:58 GMT 2024

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

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

Back to the top