posts - 0, comments - 0, trackbacks - 0, articles - 4
  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理

SWT中操作ActiveX控件

Posted on 2007-02-08 17:32 gyb 阅读(325) 评论(0)  编辑  收藏 所属分类: JAVA SWT

 

 1 package  com;
 2
 3
 4 import  org.eclipse.swt. * ;
 5 import  org.eclipse.swt.layout. * ;
 6 import  org.eclipse.swt.widgets. * ;
 7 import  org.eclipse.swt.ole.win32. * ;
 8
 9 public   class  ActiveX  {
10   private   static   final   class  FLASH_CONTROL {
11    private   static   final  String PROG_ID  =   " ShockwaveFlash.ShockwaveFlash " ;
12
13    private   static   final   class  PROPERTY {
14     private   static   final   int  MOVIE  =   120 ;
15   }

16  }

17
18   public   static   void  main(String[] args)  {
19    final  Display display  =   new  Display();
20   Shell shell  =   new  Shell(display);
21   shell.setLayout( new  FillLayout());
22   OleControlSite controlSite;
23   OleFrame frame  =   new  OleFrame(shell, SWT.NONE);
24   controlSite  =   new  OleControlSite(frame, SWT.NONE, FLASH_CONTROL.PROG_ID);
25    
26   controlSite.doVerb(OLE.OLEIVERB_INPLACEACTIVATE);
27
28    final  OleAutomation oleActiveX  =   new  OleAutomation(controlSite);
29   controlSite.dispose();
30    try   {
31   }
  catch  (Exception e)  {
32    System.out.println( " Unable to open activeX control " );
33     return ;
34   }

35
36   shell.open();
37   
38   oleActiveX.setProperty(FLASH_CONTROL.PROPERTY.MOVIE,  new  Variant[] { new  Variant( " file:///t|/ee.flv " )} )
39
40    /* 得到ActiveX中的方法和属性
41    * for(int i=-1000; i<10000; i++){
42    try{
43     String name = oleActiveX.getName(i);
44     if(name!=null){
45      System.out.print(""+i+"  ");
46      
47      Variant v = oleActiveX.getProperty(i);
48      if(v==null){
49       System.out.print("method       :"+name+":");
50       System.out.print("     ");
51      }else{
52       System.out.print("property     :"+name+":");
53       System.out.print(v);
54      }
55
56      System.out.println("    "+oleActiveX.getDocumentation(i));
57     }
58    }catch(Exception e){}
59   } */

60
61    while  ( ! shell.isDisposed())  {
62     if  ( ! display.readAndDispatch())
63     display.sleep();
64   }

65   oleActiveX.dispose();
66   display.dispose();
67  }

68 }

69