资源简介
主要涵盖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
相关资源
- js html 实现在线选座功能
-
html+ja
vasc ript捐款管理 - html实现自定emoji
- html+css仿微信聊天框架
-
ja
vasc ript过滤XSS - js和html5实现网络拓扑图
- 使用 html js 在地图上绘制网格
- jSignature 在网页上手写签名的插件(
- 客服机器人html,前端jscss实现
- jquery-scrollable.js 滚动 文本滚动
- cgi ajax js 刷新 html
- html5+exif.js+canvas
- Js鼠标移上去动态展开
- 中秋博饼源码html+js
- html 树形,树状,层级展开js代码
- easeljs-0.7.1.min.js
- js+html写的实现表格的动态增删改查和
- html+css+js制作的小黑屋A Dark Room游戏(
- HTML自动跳转页面代码
- 网络脚本语言js大作业源代码css+html
- 用于公司年会抽奖的页面+js实现
- 利用JS+CSS实现滚动表格数据展示
-
GoJS v1.5.0 ja
vasc ript Library无水印 - echarts-wordcloud.min.js
- AI智能web纯前端html+js实现的照片动起
- 仿webqq的webos框架zos,基于hoorayos2.0移
-
ja
vasc ript实现网页右下角弹出窗口 - 基于HTML5+css+JS的精美登陆注册界面
- html5全套参考手册
- angular+echart.js统计数据图表读取投屏显
评论
共有 条评论