成人无码视频,亚洲精品久久久久av无码,午夜精品久久久久久毛片,亚洲 中文字幕 日韩 无码

資訊專(zhuān)欄INFORMATION COLUMN

swt java 內(nèi)嵌ActiveX控件

mindwind / 834人閱讀

摘要:數(shù)組的長(zhǎng)度為方法參數(shù)的個(gè)數(shù)假設(shè)有四個(gè)參數(shù)方法調(diào)用調(diào)用程序內(nèi)嵌應(yīng)用程序調(diào)用簡(jiǎn)單總結(jié)

這里用的是SWT/JFace開(kāi)發(fā)application中SWT自帶的org.eclipse.swt.ole.win32 包可以支持內(nèi)嵌OLE和ActiveX。
具體用法如下:

//創(chuàng)建一個(gè)OleFrame做為OLE(或ActiveX)的框架
OleFrame oleFrame = new OleFrame(this, SWT.NONE);
//創(chuàng)建ActiveX的容器,其中的classID是ActiveX的classid,在注冊(cè)表中可以找到
OleControlSite oleControl = new OleControlSite(oleFrame, SWT.NONE, “classID”);
//OleAutomation類(lèi)用來(lái)執(zhí)行ActiveX中的方法
OleAutomation oleAutomation = new OleAutomation(oleControl);
//將ActiveX顯示在application中
oleControl.doVerb(OLE.OLEIVERB_SHOW);

調(diào)用AcitveX中方法的具體過(guò)程:
1、不帶參數(shù)的方法調(diào)用

//獲取Method Name的ID,Method Name為ActiveX中具體的方法名
int[] regspid = oleAutomation.getIDsOfNames(new String[] { "Method Name" });
int dispIdMember = regspid[0];
//方法調(diào)用
oleAutomation.invoke(dispIdMember);

2、帶參數(shù)的方法調(diào)用

//獲取Method Name的ID,Method Name為ActiveX中具體的方法名
int[] regspid = oleAutomation.getIDsOfNames(new String[] { "Method Name" });
int dispIdMember = regspid[0];
//設(shè)置方法的具體參數(shù)。Variant數(shù)組的長(zhǎng)度為Method Name方法參數(shù)的個(gè)數(shù)
//假設(shè)有四個(gè)參數(shù)
Variant[] rgvarg = new Variant[4];
rgvarg[0] = new Variant(fileID);
rgvarg[1] = new Variant(itdsURL);
rgvarg[2] = new Variant(idType);
rgvarg[3] = new Variant(reportURL);
//方法調(diào)用
oleAutomation.invoke(dispIdMember, rgvarg);

調(diào)用OLE Exemple:Java程序內(nèi)嵌Word應(yīng)用程序

package test.swt;
import java.io.File;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.ole.win32.OLE;
import org.eclipse.swt.ole.win32.OleClientSite;
import org.eclipse.swt.ole.win32.OleFrame;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Composite;
public class ActiveXTest
{
private Shell sShell = null;
private Button button = null;
private OleClientSite clientSite;
public static void main(String[] args)
{
Display display = Display.getDefault();
ActiveXTest thisClass = new ActiveXTest();
thisClass.createSShell();
thisClass.sShell.open();
while (!thisClass.sShell.isDisposed())
{
    if (!display.readAndDispatch())
    display.sleep();
}
    display.dispose();
}
/**
* This method initializes sShell
*/
private void createSShell()
{
GridData gridData = new GridData();
gridData.horizontalSpan = 2;
GridLayout gridLayout = new GridLayout();
gridLayout.numColumns = 3;
sShell = new Shell();
sShell.setText("Shell");
sShell.setLayout(gridLayout);
sShell.setSize(new Point(800, 600));
OleFrame frame = new OleFrame(sShell, SWT.NONE);
button = new Button(sShell, SWT.NONE);
button.setLayoutData(gridData);
button.setText("Save");
button.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e)
{
clientSite.save(new File("d:/test.docx"),true);
}
});
frame.setSize(800,600);
clientSite = new OleClientSite(frame, SWT.NONE,"Word.Document.8");
clientSite.setSize(400,400);
clientSite.doVerb(OLE.OLEIVERB_SHOW);
}
}

SWT調(diào)用ActiveX簡(jiǎn)單總結(jié)

public class SWT_ActivexUtil {
private OleFrame _frame;
private OleControlSite _site;
private OleAutomation _auto;

SWT_ActivexUtil(String activexId, OleControlSite site){
if(site == null){
Shell shell = new Shell();
_frame = new OleFrame(shell, SWT.NONE);
_site = new OleControlSite(_frame, SWT.NONE, activexId);
_auto = new OleAutomation(_site);
}else{
_site = site;
_auto = new OleAutomation(site);; 
}
}
public int getID(String name){
try {
int[] ids = _auto.getIDsOfNames(new String[]{name});
if(ids.length>=0)
return ids[0];
} catch (RuntimeException e) { 
e.printStackTrace(); 
}
return -1;
}
public Variant[] createVariants(String[] paras){
Variant[] vr = new Variant[paras.length];
for(int i=0;i

文章版權(quán)歸作者所有,未經(jīng)允許請(qǐng)勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。

轉(zhuǎn)載請(qǐng)注明本文地址:http://m.hztianpu.com/yun/68161.html

相關(guān)文章

  • JS實(shí)現(xiàn)打印的方式

    摘要:實(shí)現(xiàn)打印的方式方式一會(huì)彈出打印對(duì)話框,打印的是中的內(nèi)容,下面是從網(wǎng)上摘到的一個(gè)局部打印的例子,該例子的不足是打印會(huì)修改頁(yè)面的內(nèi)容。 目前正在做瀏覽器端采用js方式實(shí)現(xiàn)打印這么一個(gè)功能,JS打印實(shí)現(xiàn)的方法很多,但是兼容各個(gè)瀏覽器實(shí)現(xiàn)打印預(yù)覽的功能有些棘手,現(xiàn)將實(shí)現(xiàn)的內(nèi)容及遇到的問(wèn)題記錄下來(lái),希望有大牛看到所提的問(wèn)題后可以給予解答,在此感謝啦。 1.JS實(shí)現(xiàn)打印的方式 方式一:window...

    LucasTwilight 評(píng)論0 收藏0
  • 暫無(wú)補(bǔ)丁!新的0-Day通過(guò)濫用MS Office文檔主動(dòng)攻擊Windows

    摘要:的企業(yè)安全平臺(tái)會(huì)將有關(guān)此攻擊的警報(bào)顯示為可疑文件執(zhí)行。微軟研究人員在上重現(xiàn)了對(duì)最新的攻擊。 .markdown-body{word-break:break-word;line-height:1.75;font-weight:400;font-size:15px;overflow-x:hidden;color:#333}.markdown-body h1,.markdown-body h2,...

    zhkai 評(píng)論0 收藏0
  • 系統(tǒng)開(kāi)發(fā)內(nèi)嵌 “在線Excel” 教程 (4) – 條件格式

    摘要:條件格式可包含多個(gè)規(guī)則,每一個(gè)規(guī)則可自定義條件與格式。通過(guò)簡(jiǎn)單的規(guī)則設(shè)置,可對(duì)表單中的大量數(shù)據(jù)進(jìn)行篩選并進(jìn)行直觀地表示和顯示。下面我們來(lái)看看在條件格式中,使用不同內(nèi)置條件規(guī)則的表單最終效果。 上一講中,在數(shù)據(jù)的呈現(xiàn)方面,首先為大家介紹了迷你圖,通過(guò)一句函數(shù)調(diào)用語(yǔ)句即可直觀顯示數(shù)據(jù)。那么,除了迷你圖,SpreadJS還提供了哪些數(shù)據(jù)的可視化支持呢?今天將繼續(xù)為大家介紹條件格式。 第四講:...

    岳光 評(píng)論0 收藏0

發(fā)表評(píng)論

0條評(píng)論

閱讀需要支付1元查看
<