Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Transparent Window (SetLayeredWindowAttributes) without frame and controls
Transparent Window (SetLayeredWindowAttributes) without frame and controls [message #461467] Sun, 25 September 2005 08:35
Joe is currently offline JoeFriend
Messages: 12
Registered: July 2009
Junior Member
Hi!

I try to display a png-Image on a transparent shell (without frame).

The code below can display a transparent shell using
the (native) windows-method "SetLayeredWindowAttributes".
The problem is, that i want to remove the frame around the window.

Creating the shell with
Shell shell = new Shell(SWT.NO_TRIM)
effects that the background is no updated, when the shell is moved.

Someone has an idea how to get the the frame around the window removed,
without loosing the transparency effect?





____________________________________________________________ __

transparent shell with frame
____________________________________________________________ __

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.internal.win32.OS;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;

public class TransparentWindowTest {
Display display = null;

Shell shell = new Shell(SWT.CLOSE | SWT.MODELESS);
Label l = new Label(shell, SWT.NONE);
private RGB transparentRGB;

public TransparentWindowTest() {
this.display = shell.getDisplay();
System.load("C:\\WINDOWS\\system32\\OSEx.dll");
OS.SetWindowLong(shell.handle, OS.GWL_EXSTYLE, 0x80000);
transparentRGB = shell.getBackground().getRGB();

// args: windowHandle, rgb.red,rgg.green,rgb.blue, alpha ,dw flags
OSEx.SetLayeredWindowAttributes(this.shell.handle, transparentRGB.red,
transparentRGB.green, transparentRGB.blue, 255, 1);

l.setText("a transparent label");
l.setSize(100, 20);

this.shell.addPaintListener(new PaintListener() {

public void paintControl(PaintEvent event) {
Image imgTest = new Image(Display.getDefault(), "test.png");
event.gc.drawImage(imgTest, 0, 0);
}

}

);

this.shell.setSize(256, 256);
this.shell.open();
this.shell.update();

while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
}

public static void main(String[] args) {

new TransparentWindowTest();

}


}
Previous Topic:AWT.requestFocus deadlocks with SWT.EventQueue.invokeAndWait
Next Topic:Painting on a GC at a decent speed
Goto Forum:
  


Current Time: Tue Oct 17 07:58:21 GMT 2017

Powered by FUDForum. Page generated in 0.01906 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software