java 移动窗口,如何使用Java在屏幕上移动Windows窗口?

I've been contemplating making a window manager with a GUI, probably in Java. However, I'm struggling to figure out the best way to move windows not owned by my program.

So far, it would seem I should use JNI to interface with the Windows API, but I haven't found any helpful examples.

Does anyone know how to do this?

Thanks!

PS. I'm not necessarily tied to Java, if there is a better language to do this in.

解决方案

If the purpose is to have a fast window manager you are certainly better off with C++ or C#, or maybe even Delphi.

But if you are most familiar with Java it can be done.

If you choose the (aging) JNI you would have to write a DLL in C or Delphi that you Java application will use. You should use JNA instead to access the Windows' window handling API functions.

Some of the functions you would use are:

HWND WINAPI GetWindow(HWND hWnd, UINT uCmd);

HWND WINAPI FindWindow(LPCTSTR lpClassName, LPCTSTR lpWindowName);

BOOL WINAPI EnumWindows(WNDENUMPROC lpEnumFunc, LPARAM lParam);

HWND WINAPI WindowFromPoint(POINT Point);

BOOL WINAPI MoveWindow(HWND hWnd, int X, int Y, int nWidth, int nHeight, BOOL bRepaint);

Once you get the window handle (HWND) you can do whatever you like with that window.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值