资源简介
主要涵盖jacob调用ocx控件的方法以及事件的源码demo,同时还有html页面中通过js调用ocx控件的代码示例,并附带自己开发的ocx控件,运行时需要注意先注册控件,并且配置好jacob安装包。

代码片段和文件信息
package main;
import com.jacob.activeX.ActiveXComponent;
import com.jacob.com.ComThread;
import com.jacob.com.Dispatch;
import com.jacob.com.DispatchEvents;
import com.jacob.com.Variant;
import com.jacob.test.baseTestCase;
public class MyOcxTest extends baseTestCase {
/**
* The actual work of running the test.
*
* @param waitForQuit
* @param urls
*/
public void runTheTest() {
// this line starts the pump but it runs fine without it
ComThread.startMainSTA();
// Run the test in a thread. Lets us test running out of “main“ thread
IETestThread aThread = new IETestThread();
aThread.start();
while (aThread.isAlive()) {
try {
Thread.sleep(250);
} catch (InterruptedException e) {
// done with the sleep
}
}
ComThread.quitMainSTA();
System.out.println(“Main: did quit main sta in thread “
+ Thread.currentThread().getName());
if (aThread.threadFailedWithException != null) {
aThread.threadFailedWithException.printStackTrace();
fail(“caught an unexpected exception “
+ aThread.threadFailedWithException);
}
}
}
class IETestThread extends Thread {
/** flag that says we got a quit message from IE */
public static boolean quitHandled = false;
/**
* determines if we wait until last quit call back received before
* terminating
*/
private static boolean waitUntilReceivedQuitCallback = true;
/**
* the places we should navigate to
*/
private static String[] targets = null;
/**
* holds any caught exception so the main/test case can see them
*/
public Throwable threadFailedWithException = null;
/**
* constructor for the test thread
*
* @param beNeat
* should we wait until quit received
* @param urls
* the web pages we will navigate to
*/
public IETestThread() {
super();
}
/**
* Run through the addresses passed in via the constructor
*/
@Override
public void run() {
// pick a time that lets sourceforge respond (in msec)
int delay = 3000;
// pre-1.14 paired with statement below that blows up
ComThread.InitMTA();
ActiveXComponent ie = new ActiveXComponent(
“DEMO.DemoCtrl.1“);
try {
MyOcxEvents ieE = new MyOcxEvents();
new DispatchEvents(ie ieE “DEMO.DemoCtrl.1“);
System.out.println(“MyOcxEvents : Did hookup event listener“);
Dispatch.call(ie “Hello“ “HelloActiveX!“);
} catch (Exception e) {
threadFailedWithException = e;
e.printStackTrace();
} catch (Throwable re) {
threadFailedWithException = re;
re.printStackTrace();
} finally {
System.out.println(“IETestThread: Did send Quit“);
}
// a value is set to false if we try to crash VM by leaving before
// callbacks all received
if (waitUntilReceivedQuitCallback) {
System.out.println(“IETestThread: Waiting until we‘ve received quit callback“);
// wait a little while for it to end
while (
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 129536 2018-07-16 14:24 jacob-js调用ocx\Demo.ocx
文件 1129 2018-07-16 14:26 jacob-js调用ocx\index.html
文件 4162 2018-07-16 14:33 jacob-js调用ocx\MyOcxTest.java
文件 297 2018-07-16 11:43 jacob-js调用ocx\MyTest.java
目录 0 2018-07-16 17:07 jacob-js调用ocx
----------- --------- ---------- ----- ----
135124 5
相关资源
- 简易京东网页HTML代码(HTMLamp;JS;)
- 人才招聘资讯博客HTML模板手机版自适
- jquerybootstrap强大的后台框架(Preclin
- js实现垂直向上滚动(文本的HTML标记
- 简单解一元二次方程Bean+servlet+jsp
- js实现购物车实时计算
- HTML5创意设计师个人简历响应式模板
- 购物商城 html5+css+JS+Bootstrap前端框架
- 弹窗插件(bs4.pop.js)
- jq/js调用本地电脑摄像头实现拍照和截
- html/css/js实现罗盘时钟。
- 登录代码JS/HTML
- jQuery蜘蛛纸牌电脑版游戏源码
- Vue.js智能社视频教程
- Vuejs文件上传组件多文件上传
- polyfilll.min.js压缩版
- ht.js html5 canvas2d3d教程手册
- Uploadify HTML5 版 / Jquery上传插件 全JS
- poi3.8 实现word07docx转为html
- nw.js打包处理教程(将html打包成PC应用
- h5校验身份证号码
- HTML5 canvas打砖块射击小游戏.zip
- tonyCode抽奖系统原HTML+JS抽奖系统V4.0
- js课程设计打飞机
- html+Js抽奖系统 2.0.1
- 《Java+Web程序设计任务教程》_线下题
- HTML+CSS+JS构建的电商网站页面源码
- 46种常见的浏览器兼容性问题大汇总
- js excel 批量复制数据到 html新
- GoJs无水印版js文件(go.js)_v1.8.8
评论
共有 条评论