这些是winapi方法
BOOL WINAPI SetWindowPlacement(
_In_ HWND hWnd,
_In_ const WINDOWPLACEMENT *lpwndpl
);
typedef struct tagWINDOWPLACEMENT {
UINT length;
UINT flags;
UINT showCmd;
POINT ptMinPosition;
POINT ptMaxPosition;
RECT rcNormalPosition;
} WINDOWPLACEMENT, *PWINDOWPLACEMENT, *LPWINDOWPLACEMENT;
我的Java代码: -
class WINDOWPLACEMENT{
public int length;
public int flags;
public int showCmd;
public POINT ptMinPosition;
public POINT ptMaxPosition;
public RECT rcNormalPosition;
}
WINDOWPLACEMENT wind = new WINDOWPLACEMENT();
User32Extra.INSTANCE.GetWindowPlacement(hwndLSM, wind);
错误是
java.lang.IllegalArgumentException:函数GetWindowPlacement的参数1处的不支持的参数类型jna.extra.WINDOWPLACEMENT
如何在JNA中使用GetWindowPlacement / SetWindowPlacement?
答案 0 :(得分:1)
java.extra.WINDOWPLACEMENT
必须延长com.sun.jna.Structure
并正确实施getFieldOrder()
。
修改强>
在构造函数中设置长度,getFieldOrder()
定义:
public class WINDOWPLACEMENT extends Structure {
public WINDOWPLACEMENT() {
this.length = size();
}
public List getFieldOrder() {
return Arrays.asList("length", "flags", "showCmd", "ptMinPosition", "ptMaxPosition", "rcNormalPosition");
}
// ...
}