jnative

http://jnative.free.fr/SPIP-v1-8-3/article.php3?id_article=4

public class JnativeRect extends AbstractBasicData<JnativeRect>{

protected JnativeRect(JnativeRect lValue) throws NativeException {
super(null);
createPointer();
mValue = this;
}

public int left;
public int top;
public int right;
public int bottom;

@Override
public JnativeRect getValueFromPointer() throws NativeException {
// TODO Auto-generated method stub
return null;
}

@Override
public int getSizeOf() {
return 4*4;
}

@Override
public Pointer createPointer() throws NativeException {
pointer = new Pointer(MemoryBlockFactory.createMemoryBlock(getSizeOf()));
return pointer;
}

}

public class Demo {
public static void main(String[] args) {
test();
}

public static void test(){
Display dis = new Display();
Shell shell = new Shell(dis,SWT.DIALOG_TRIM|SWT.RESIZE);
shell.setSize(800,600);
shell.setLayout(new FillLayout());
shell.setText("S2 Graph from SWT");
shell.open();
dosomething(shell);
while(!shell.isDisposed()){
if(!dis.readAndDispatch()){
dis.sleep();
}
}
dis.dispose();
}
private static void dosomething(Shell shell) {
try {
HWND hWnd = User32.FindWindow(null,"S2 Graph from SWT");
//m_hPE = PEcreate(PECONTROL_SGRAPH, WS_VISIBLE, &rect, hWnd, 1001);
System.loadLibrary("pegrp32c");// InterfaceFun是dll文件
// 參數說明InterfaceFun dll名,AddZhiYe函數名
JNative jnative = new JNative("pegrp32c", "PEcreate");
// 設置此函數的返回值
int i = 0;
// 賦予參數值
jnative.setParameter(i++,300);
jnative.setParameter(i++,org.xvolks.jnative.util.constants.winuser.WindowsConstants.WS_VISIBLE);

JnativeRect jr = new JnativeRect(null);
jr.getPointer().setIntAt(0, shell.getLocation().x);
jr.getPointer().setIntAt(4, shell.getLocation().y);
jr.getPointer().setIntAt(8, shell.getLocation().x+400);
jr.getPointer().setIntAt(12, shell.getLocation().y+400);
jnative.setParameter(i++,jr.getPointer());

jnative.setParameter(i++,shell.handle);
jnative.setParameter(i++,1001);
// 函數執行
jnative.invoke();
} catch (Exception e) {
e.printStackTrace();
}

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值