Chinaunix首页 | 论坛 | 博客
  • 博客访问: 50796
  • 博文数量: 13
  • 博客积分: 1465
  • 博客等级: 上尉
  • 技术积分: 130
  • 用 户 组: 普通用户
  • 注册时间: 2006-06-01 10:15
文章分类

全部博文(13)

文章存档

2011年(2)

2008年(11)

我的朋友

分类: Java

2011-06-21 08:33:56

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();
             }
             
            }
       }
}
}

阅读(447) | 评论(0) | 转发(0) |
0

上一篇:编码规范工具 Rule compliance-Java

下一篇:没有了

给主人留下些什么吧!~~