|
Re: Failed to create Ole Client [message #443130 is a reply to message #443128] |
Mon, 20 September 2004 05:56 |
hechengrong 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);
> }
> }
|
|
|
|
Powered by
FUDForum. Page generated in 0.03255 seconds