| How to prevent resize event to pass to a child [message #540182] |
Tue, 15 June 2010 06:02  |
Marton Sigmond Messages: 70 Registered: July 2009 Location: Hungary |
Member |
|
|
Hi,
I have an SWT (RCP) application.
I embed a native window into the widget hierarchy (win32):
// Remove window decoration
embedComp = new Composite(parent, SWT.EMBEDDED);
OS.SetParent(winHandle, embedComp.handle);
Since the embedded native window is heavyweight, I do not want it to be resized as the user drags the border of the SWT Shell (only when the user finally releases the mouse button).
I tried to filter the Resize events on the embedding Composite, but did not help:
display.addFilter(SWT.Resize, new Listener() {
@Override
public void handleEvent(final Event event) {
if (embedComp == event.widget) {
event.doit = false;
event.type = SWT.None;
}
}
}); The native window still gets resized as the user drags the Shell border.
Please let me know if you have any suggestion.
Thanks,
Marton
|
|
|
| Re: How to prevent resize event to pass to a child [message #540188 is a reply to message #540182] |
Tue, 15 June 2010 06:36   |
Vijay Raj Messages: 600 Registered: July 2009 |
Senior Member |
|
|
display filters work only at the SWT level ,they dont block the native events like resize...
whats the layout of your shell on which you are placing your win32 window.
one thing you can do is add a control listener on the shell and on controlresized apply the layout on the shell and do a .layout
and may be remove the layout after done.
---------------------
why, mr. Anderson, why, why do you persist?
Because I Choose To.
Regards,
Vijay
|
|
|
|
| Re: How to prevent resize event to pass to a child [message #540290 is a reply to message #540188] |
Tue, 15 June 2010 10:32  |
Marton Sigmond Messages: 70 Registered: July 2009 Location: Hungary |
Member |
|
|
Thanks for the idea, I could use it successfully.
I created a custom Layout, and a shell control listener within it.
When a resize event came in, I set a flag to forbid the layout() method to change anything:
public class MyLayout extends Layout {
public MyLayout(final Composite composite) {
final Shell shell = PlatformUI.getWorkbench()
.getActiveWorkbenchWindow().getShell();
final ControlListener ctrlListener = new ControlAdapter() {
@Override
public void controlResized(final ControlEvent event) {
resizeForbidden = true;
scheduleDoLayout(DO_LAYOUT_DELAY);
}
};
shell.addControlListener(ctrlListener);
composite.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
shell.removeControlListener(ctrlListener);
}
});
}
@Override
protected void layout(final Composite composite, final boolean flushCache) {
if (resizeForbidden) {
return;
}
When no more resize events came for 2 secs, I reset the flag, and invoke the composite's layout() method.
Thanks again!
Marton
|
|
|
Powered by
FUDForum. Page generated in 0.02874 seconds