Autor Thema: swt/eclipse/workspace code, um ole/ActiveX einzubinden  (Gelesen 1713 mal)

Marinero Atlántico

  • Gast
Hi,

Code
public class Test {
// ... imports
	public static void main(String[] args) {
				
		String progID = "MsPowerPoint";
		
		Display display = new Display ();
		Shell shell = new Shell(display);
	
		OleFrame clientFrame = new OleFrame(shell, SWT.CLIP_CHILDREN);
		clientFrame.setBackground(
				JFaceColors.getBannerBackground(clientFrame.getDisplay()));
		
		clientFrame.setBounds(shell.getClientArea());

		OleAutomation auto = null;
		try {
                        // You can also play with OleControlSite if you waqnt
			//OleControlSite site = 
                        //        new OleControlSite(clientFrame, SWT.NONE, progID);
			File file = new File(
                           "F:\\shared\\Mis Articulos\\aejac\\El Futuro De Java.ppt"); 
			OleClientSite site = 
                           new OleClientSite(clientFrame, SWT.NONE, file);	
			site.setBackground(JFaceColors.getBannerBackground(
                            clientFrame.getDisplay()));
			auto = new OleAutomation(site);
			
			site.doVerb(OLE.OLEIVERB_SHOW);

			
		} catch (SWTException ex) {
			System.out.println("Unable to open type library for "+progID);
			return;
		}
		
		/*Label label = new Label (shell, SWT.CENTER);
		label.setText ("Hello_world");
		label.setBounds (shell.getClientArea ());*/
		shell.open();	
		while (!shell.isDisposed ()) {
			if (!display.readAndDispatch ()) display.sleep ();
		}

		display.dispose ();		
	
	}
}

... geklaut von http://jroller.com/page/mpermar/20041222#how_to_open_ms_powerpoint
... nicht ganz sicher, aber ich glaube vor display.dispose() müsste evtl. noch auto.dispose() oder/und site.dispose() kommen. Bin mir aber nicht sicher.

werde dem nachgehen.

Axel

 

Impressum Atnotes.de  -  Powered by Syslords Solutions  -  Datenschutz