[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
|
[news.eclipse.tools] Re: [SWT] Ole Browser View Resizing to a Little Box
|
"Veronika Irvine" <veronika_irvine@xxxxxxx> wrote in message
news:b2e33f$auk$1@xxxxxxxxxxxxxxxx
> John seems to have fixed his problem. Ron, do you still want assistance?
> If so, please post some code and I will have a look.
Yes, I need help (that's what people tell me anyway). :-)
I have written a small test program that demonstrates the problem. The test
program basically allows you to open and view an image file (just about any
format) using an ActiveX imaging control by LeadTools. Also, I have
confirmed that the height and width of the control are getting set to 0
(using the window spy program that comes with VS). This happens in at least
two cases:
1. The first time you click on the control after the program loads. The
control "comes back" if you resize the main window. However, it only
happens if there is a button on the toolbar (look for the line marked
"problem line" in the code below). If the "problem line" is commented out,
it appears to work correctly.
2. When you use File | Open and then dismiss the dialog (either by
selecting a file or pressing Cancel). This can be seen visually by opening
an image, resizing the window smaller than the image (causing scrollbars to
show), then opening and dismissing the file dialog. When you do this the
scrollbars will disappear because the control has been resized to zero width
and height (the image will still be visible; I think SWT or Windows is
persisting the background). Note this happens regardless of what you do
with the toolbar (unlike #1).
This very much seems like some kind of activation/focus issue. If the test
code below doesn't have any obvious problems, I can send you the OCX in
question which will allow you to run it.
Thanks in advance,
Ron
----- BEGIN -----
package com.sourceprose.ron.swttest;
import org.eclipse.jface.action.*;
import org.eclipse.jface.resource.*;
import org.eclipse.jface.window.ApplicationWindow;
import org.eclipse.swt.SWT;
import org.eclipse.swt.ole.win32.*;
import org.eclipse.swt.widgets.*;
public class LeadJFaceTest extends ApplicationWindow {
private static final int FUNC_LOAD = 0x152;
private static final int PROP_PAINTSIZEMODE = 0x9a;
private static final int PAINTSIZEMODE_FIT = 3;
OleAutomation mOleAutomation;
public LeadJFaceTest() {
super(null);
}
protected void configureShell(Shell shell) {
super.configureShell(shell);
shell.setText("JFace/Lead Test Rig");
}
protected MenuManager createMenuManager() {
MenuManager menuManager = new MenuManager();
menuManager.add(createFileMenu());
return menuManager;
}
protected ToolBarManager createToolBarManager(int style) {
ToolBarManager toolbarManager = new ToolBarManager(style);
toolbarManager.add(createOpenAction()); // <- problem line
return toolbarManager;
}
protected Control createContents(Composite parent) {
OleFrame oleFrame = new OleFrame(parent, SWT.NONE);
OleControlSite oleControl = new OleControlSite(oleFrame, SWT.BORDER,
"LEAD.LeadCtrl.121");
oleControl.doVerb(OLE.OLEIVERB_SHOW);
mOleAutomation = new OleAutomation(oleControl);
return oleFrame;
}
protected void handleShellCloseEvent() {
setReturnCode(CANCEL);
close();
}
private void createComponents() {
addMenuBar();
addToolBar(SWT.FLAT | SWT.WRAP);
setBlockOnOpen(true);
}
private MenuManager createFileMenu() {
MenuManager menu = new MenuManager("&File" , "Id01");
menu.add(createOpenAction());
return menu;
}
private Action createOpenAction() {
return new Action() {
public ImageDescriptor getImageDescriptor() {
return ImageDescriptor.createFromFile(LeadJFaceTest.class,
"icons/openFolder.gif");
}
public String getText() {
return "&Open";
}
public void run() {
FileDialog dialog = new FileDialog(getShell(), SWT.OPEN);
dialog.open();
if (dialog.getFileName().length() != 0) {
mOleAutomation.invoke(FUNC_LOAD, new Variant[] {new
Variant(dialog.getFilterPath() + java.io.File.separator +
dialog.getFileName()), new Variant(0), new Variant(0), new Variant(1)});
}
}
};
}
public static void main(String[] args) {
LeadJFaceTest app = new LeadJFaceTest();
app.createComponents();
app.open();
Display.getCurrent().dispose();
}
}
----- END -----