| [news.eclipse.platform.swt] org.eclipse.swt.SWTException: Failed to change Variant type result = -1 |
org.eclipse.swt.SWTException: Failed to change Variant type result = -1
at org.eclipse.swt.ole.win32.OLE.error(OLE.java:332)
at org.eclipse.swt.ole.win32.Variant.getAutomation(Variant.java:200)
at Main.ShellExplorer.<init>(ShellExplorer.java:38)
at Main.ShellExplorer.main(ShellExplorer.java:52)
Exception in thread "main"
import
org.eclipse.swt.SWT;import org.eclipse.swt.layout.RowLayout;
import
org.eclipse.swt.ole.win32.OLE;import
org.eclipse.swt.ole.win32.OleAutomation;import
org.eclipse.swt.ole.win32.OleControlSite;import
org.eclipse.swt.ole.win32.OleFrame;import
org.eclipse.swt.ole.win32.Variant;import
org.eclipse.swt.widgets.Display;import
org.eclipse.swt.widgets.Shell;public
class ShellExplorer { protected static Display display; protected static Shell shell; protected OleAutomation automationHtml; protected OleControlSite controlSiteHtml; protected OleFrame oleFrameHtml; public ShellExplorer(){ oleFrameHtml = new OleFrame(shell, SWT.NONE); controlSiteHtml = new OleControlSite(oleFrameHtml, SWT.NONE, "Shell.Explorer"); //webbrowser controlSiteHtml.setSize(100, 100); controlSiteHtml.doVerb(OLE.OLEIVERB_SHOW); controlSiteHtml.doVerb(OLE.OLEIVERB_INPLACEACTIVATE); automationHtml = new OleAutomation(controlSiteHtml);int[] rgdispid = automationHtml.getIDsOfNames(new String[]{"Document"}); //get a document int dispIdMember = rgdispid[0]; Variant varDocument = automationHtml.getProperty(dispIdMember); OleAutomation doc = varDocument.getAutomation(); int[] rgdispid2 = doc.getIDsOfNames(new String[]{"write"}); //write in a document Variant[] rgvarg = new Variant[1]; rgvarg[0] = new Variant("<body>browser</body>"); automationHtml.invoke(rgdispid2[0], rgvarg); } public static void main (String [] args) { display = new Display (); shell = new Shell (display); RowLayout fl = new RowLayout(); shell.setLayout(fl); ShellExplorer se = new ShellExplorer(); shell.pack (); shell.open (); while (!shell.isDisposed ()) { if (!display.readAndDispatch ()) display.sleep (); } display.dispose (); }
}