SWT OLE and PowerPoint- Control Order Matters? [message #535309] |
Sat, 22 May 2010 03:25 |
No real name Messages: 17 Registered: March 2010 |
Junior Member |
|
|
I have an embedded OLE widget in my SWT app. When I add another control (i.e. a button) after it, things show OK. However, when I add the control before the OLE widget, the PowerPoint content is not show. Below is the example code with the 'addBefore' flag. This requires a dummy PowerPoint file stub.pptx in 'user.home'. I have searched a bunch but have not found anything. Any suggestions?
import java.io.File;
import org.eclipse.swt.SWT;
import org.eclipse.swt.SWTError;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.ole.win32.OLE;
import org.eclipse.swt.ole.win32.OleClientSite;
import org.eclipse.swt.ole.win32.OleFrame;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class Snippet263D {
public static void main(String[] args) {
boolean addBefore = false;
OleClientSite clientSite;
OleFrame oleFrame;
Display display = new Display();
final Shell shell = new Shell(display);
shell.setText("PowerPoint Example");
shell.setLayout(new FillLayout());
Composite panel = new Composite(shell, SWT.BORDER);
FillLayout layout = new FillLayout();
panel.setLayout(layout);
Button bb = null;
if (addBefore)
bb = new Button(panel, SWT.PUSH);
try {
oleFrame = new OleFrame(panel, SWT.NONE);
String home = System.getProperty("user.home");
File fileBeingEdited = new File(home + "/stub.pptx");
clientSite = new OleClientSite(oleFrame, SWT.NONE, fileBeingEdited);
clientSite.doVerb(OLE.OLEIVERB_INPLACEACTIVATE);
} catch (SWTError e) {
e.printStackTrace();
display.dispose();
return;
}
if (! addBefore)
bb = new Button(panel, SWT.PUSH);
bb.setText("Widget 2");
shell.setSize(800, 600);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
}
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04745 seconds