How to use Java to move Windows windows around on screen?

家住魔仙堡 提交于 2019-12-01 10:29:56

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.

EnumWindows function reference at MSDN

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!