List of usage examples for org.eclipse.swt.ole.win32 OleFrame OleFrame
public OleFrame(Composite parent, int style)
From source file:MainClass.java
public static void main(String[] args) { final Display display = new Display(); Shell shell = new Shell(display); shell.setSize(600, 400);// w ww. ja v a 2 s . c o m shell.setLayout(new FillLayout()); OleControlSite oleControlSite; OleFrame oleFrame = new OleFrame(shell, SWT.NONE); oleControlSite = new OleControlSite(oleFrame, SWT.NONE, "Shell.Explorer"); oleControlSite.doVerb(OLE.OLEIVERB_INPLACEACTIVATE); shell.open(); final OleAutomation browser = new OleAutomation(oleControlSite); int[] browserIDs = browser.getIDsOfNames(new String[] { "Navigate", "URL" }); Variant[] address = new Variant[] { new Variant("http://www.java2s.com") }; browser.invoke(browserIDs[0], address, new int[] { browserIDs[1] }); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } browser.dispose(); display.dispose(); }
From source file:SWTOleFrame.java
public static void main(String[] args) { final Display display = new Display(); Shell shell = new Shell(display); shell.setSize(600, 400);/*from w w w.j a v a2 s . c om*/ shell.setLayout(new FillLayout()); OleControlSite oleControlSite; OleFrame oleFrame = new OleFrame(shell, SWT.NONE); oleControlSite = new OleControlSite(oleFrame, SWT.NONE, "Shell.Explorer"); oleControlSite.doVerb(OLE.OLEIVERB_INPLACEACTIVATE); shell.open(); final OleAutomation browser = new OleAutomation(oleControlSite); int[] browserIDs = browser.getIDsOfNames(new String[] { "Navigate", "URL" }); Variant[] address = new Variant[] { new Variant("http://www.oreilly.com") }; browser.invoke(browserIDs[0], address, new int[] { browserIDs[1] }); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } browser.dispose(); display.dispose(); }
From source file:Snippet187.java
public static void main(String[] args) { final Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); OleControlSite controlSite;//from ww w. j ava 2 s . co m try { OleFrame frame = new OleFrame(shell, SWT.NONE); controlSite = new OleControlSite(frame, SWT.NONE, "Shell.Explorer"); controlSite.doVerb(OLE.OLEIVERB_INPLACEACTIVATE); } catch (SWTError e) { System.out.println("Unable to open activeX control"); return; } // IWebBrowser final OleAutomation webBrowser = new OleAutomation(controlSite); // When the document is loaded, access the document object for the new // page // and evalute expression using Script. int DownloadComplete = 104; controlSite.addEventListener(DownloadComplete, new OleListener() { public void handleEvent(OleEvent event) { int[] htmlDocumentID = webBrowser.getIDsOfNames(new String[] { "Document" }); if (htmlDocumentID == null) return; Variant pVarResult = webBrowser.getProperty(htmlDocumentID[0]); if (pVarResult == null || pVarResult.getType() == 0) return; // IHTMLDocument2 OleAutomation htmlDocument = null; try { htmlDocument = pVarResult.getAutomation(); pVarResult.dispose(); int[] scriptID = htmlDocument.getIDsOfNames(new String[] { "Script" }); if (scriptID == null) return; pVarResult = htmlDocument.getProperty(scriptID[0]); if (pVarResult == null || pVarResult.getType() == 0) return; OleAutomation htmlWindow = null; try { // IHTMLWindow2 htmlWindow = pVarResult.getAutomation(); pVarResult.dispose(); int[] evaluateID = htmlWindow.getIDsOfNames(new String[] { "evaluate" }); if (evaluateID == null) return; String expression = "5+Math.sin(9)"; Variant[] rgvarg = new Variant[] { new Variant(expression) }; pVarResult = htmlWindow.invoke(evaluateID[0], rgvarg, null); if (pVarResult == null || pVarResult.getType() == 0) return; System.out.println(expression + " =" + pVarResult.getString()); } finally { htmlWindow.dispose(); } } finally { htmlDocument.dispose(); } } }); // Navigate to a web site int[] ids = webBrowser.getIDsOfNames(new String[] { "Navigate", "URL" }); Variant[] rgvarg = new Variant[] { new Variant( "http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet187.html") }; int[] rgdispidNamedArgs = new int[] { ids[1] }; webBrowser.invoke(ids[0], rgvarg, rgdispidNamedArgs); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } // Remember to release OleAutomation Object webBrowser.dispose(); display.dispose(); }
From source file:Snippet81.java
public static void main(String[] args) { if (args.length == 0) { System.out.println("Usage: java Main <program id>"); return;/*from ww w . j a v a 2 s .c o m*/ } String progID = args[0]; Shell shell = new Shell(); OleFrame frame = new OleFrame(shell, SWT.NONE); OleControlSite site = null; OleAutomation auto = null; try { site = new OleControlSite(frame, SWT.NONE, progID); auto = new OleAutomation(site); } catch (SWTException ex) { System.out.println("Unable to open type library for " + progID); return; } TYPEATTR typeattr = auto.getTypeInfoAttributes(); if (typeattr != null) { if (typeattr.cFuncs > 0) System.out.println("Functions for " + progID + " :\n"); for (int i = 0; i < typeattr.cFuncs; i++) { OleFunctionDescription data = auto.getFunctionDescription(i); String argList = ""; int firstOptionalArgIndex = data.args.length - data.optionalArgCount; for (int j = 0; j < data.args.length; j++) { argList += "["; if (j >= firstOptionalArgIndex) argList += "optional, "; argList += getDirection(data.args[j].flags) + "] " + getTypeName(data.args[j].type) + " " + data.args[j].name; if (j < data.args.length - 1) argList += ", "; } System.out.println(getInvokeKind(data.invokeKind) + " (id = " + data.id + ") : " + "\n\tSignature : " + getTypeName(data.returnType) + " " + data.name + "(" + argList + ")" + "\n\tDescription : " + data.documentation + "\n\tHelp File : " + data.helpFile + "\n"); } if (typeattr.cVars > 0) System.out.println("\n\nVariables for " + progID + " :\n"); for (int i = 0; i < typeattr.cVars; i++) { OlePropertyDescription data = auto.getPropertyDescription(i); System.out.println("PROPERTY (id = " + data.id + ") :" + "\n\tName : " + data.name + "\n\tType : " + getTypeName(data.type) + "\n"); } } auto.dispose(); shell.dispose(); }
From source file:org.eclipse.swt.snippets.Snippet261.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setText("Excel Example"); shell.setLayout(new FillLayout()); try {// w w w .ja v a2 s . c o m OleFrame frame = new OleFrame(shell, SWT.NONE); new OleClientSite(frame, SWT.NONE, "Excel.Sheet"); addFileMenu(frame); } catch (SWTError e) { System.out.println("Unable to open activeX control"); display.dispose(); return; } shell.setSize(800, 600); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:org.eclipse.swt.snippets.Snippet187.java
public static void main(String[] args) { final Display display = new Display(); Shell shell = new Shell(display); shell.setText("Snippet 187"); shell.setLayout(new FillLayout()); OleControlSite controlSite;/* w ww . j a v a 2 s . c o m*/ try { OleFrame frame = new OleFrame(shell, SWT.NONE); controlSite = new OleControlSite(frame, SWT.NONE, "Shell.Explorer"); controlSite.doVerb(OLE.OLEIVERB_INPLACEACTIVATE); } catch (SWTError e) { System.out.println("Unable to open activeX control"); display.dispose(); return; } // IWebBrowser final OleAutomation webBrowser = new OleAutomation(controlSite); // When the document is loaded, access the document object for the new page // and evalute expression using Script. int DownloadComplete = 104; controlSite.addEventListener(DownloadComplete, new OleListener() { @Override public void handleEvent(OleEvent event) { int[] htmlDocumentID = webBrowser.getIDsOfNames(new String[] { "Document" }); if (htmlDocumentID == null) return; Variant pVarResult = webBrowser.getProperty(htmlDocumentID[0]); if (pVarResult == null || pVarResult.getType() == 0) return; //IHTMLDocument2 OleAutomation htmlDocument = null; try { htmlDocument = pVarResult.getAutomation(); pVarResult.dispose(); int[] scriptID = htmlDocument.getIDsOfNames(new String[] { "Script" }); if (scriptID == null) return; pVarResult = htmlDocument.getProperty(scriptID[0]); if (pVarResult == null || pVarResult.getType() == 0) return; OleAutomation htmlWindow = null; try { //IHTMLWindow2 htmlWindow = pVarResult.getAutomation(); pVarResult.dispose(); int[] evaluateID = htmlWindow.getIDsOfNames(new String[] { "evaluate" }); if (evaluateID == null) return; String expression = "5+Math.sin(9)"; Variant[] rgvarg = new Variant[] { new Variant(expression) }; pVarResult = htmlWindow.invoke(evaluateID[0], rgvarg, null); if (pVarResult == null || pVarResult.getType() == 0) return; System.out.println(expression + " =" + pVarResult.getString()); } finally { htmlWindow.dispose(); } } finally { htmlDocument.dispose(); } } }); // Navigate to a web site int[] ids = webBrowser.getIDsOfNames(new String[] { "Navigate", "URL" }); Variant[] rgvarg = new Variant[] { new Variant( "http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet187.html") }; int[] rgdispidNamedArgs = new int[] { ids[1] }; webBrowser.invoke(ids[0], rgvarg, rgdispidNamedArgs); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } //Remember to release OleAutomation Object webBrowser.dispose(); display.dispose(); }
From source file:org.eclipse.swt.snippets.Snippet264.java
public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display); shell.setText("Media Player Example"); shell.setLayout(new FillLayout()); try {/* w ww . j a v a 2 s . c om*/ OleFrame frame = new OleFrame(shell, SWT.NONE); clientSite = new OleClientSite(frame, SWT.NONE, "MPlayer"); addFileMenu(frame); } catch (SWTError e) { System.out.println("Unable to open activeX control"); display.dispose(); return; } shell.setSize(800, 600); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:org.eclipse.swt.snippets.Snippet263.java
public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display); shell.setText("PowerPoint Example"); shell.setLayout(new FillLayout()); try {/*www . j av a2s . c o m*/ OleFrame frame = new OleFrame(shell, SWT.NONE); clientSite = new OleClientSite(frame, SWT.NONE, "PowerPoint.Slide"); addFileMenu(frame); } catch (SWTError e) { System.out.println("Unable to open activeX control"); display.dispose(); return; } shell.setSize(800, 600); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:org.eclipse.swt.snippets.Snippet265.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setText("Media Player Example"); shell.setLayout(new FillLayout()); try {/* w w w. ja va 2s. c o m*/ OleFrame frame = new OleFrame(shell, SWT.NONE); clientSite = new OleClientSite(frame, SWT.NONE, "WMPlayer.OCX"); clientSite.doVerb(OLE.OLEIVERB_INPLACEACTIVATE); addFileMenu(frame); } catch (SWTError e) { System.out.println("Unable to open activeX control"); display.dispose(); return; } shell.setSize(800, 600); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:org.eclipse.swt.snippets.Snippet262.java
public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display); shell.setText("Word Example"); shell.setLayout(new FillLayout()); try {/*from w w w.j av a 2 s . co m*/ frame = new OleFrame(shell, SWT.NONE); clientSite = new OleClientSite(frame, SWT.NONE, "Word.Document"); addFileMenu(frame); } catch (SWTError e) { System.out.println("Unable to open activeX control"); display.dispose(); return; } shell.setSize(800, 600); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }