import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.internal.win32.OS;
import org.eclipse.swt.internal.win32.TCHAR;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class TransWin {
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display, SWT.CLOSE);
shell.setSize(new Point(400, 400));
shell.setLayout(new FillLayout());
shell.setText("trans window 50%");
shell.open();
OS.SetWindowLong(shell.handle, OS.GWL_EXSTYLE, OS.GetWindowLong(
shell.handle, OS.GWL_EXSTYLE) ^ 0x80000);
TCHAR lpLibFileName = new TCHAR(0, "user32.dll", true);
int hInst = OS.LoadLibrary(lpLibFileName);
if (hInst != 0) {
String name = "SetLayeredWindowAttributes\0";
byte[] lpProcName = new byte[name.length()];
for (int i = 0; i < lpProcName.length; i++) {
lpProcName[i] = (byte) name.charAt(i);
}
int fun = OS.GetProcAddress(hInst, lpProcName);
if (fun != 0) {
OS.CallWindowProc(fun, shell.handle, 0, 150, 2);
/*
* int org.eclipse.swt.internal.win32.OS.CallWindowProc(int lpPrevWndFunc, int hWnd, int Msg, int wParam, int lParam)
*/
}
OS.FreeLibrary(hInst);
while (!shell.isDisposed()){
if (!display.readAndDispatch()){
display.sleep();
}
}
}
}
}
阅读(481) | 评论(0) | 转发(0) |