黑马程序员技术交流社区

标题: swt如何给OleClientSite添加滚动条 [打印本页]

作者: jttsai    时间: 2013-7-23 13:54
标题: swt如何给OleClientSite添加滚动条
最近工作中遇到在swt程序中打开word文件,
察看了文档后OleClientSite能够实现这个功能,可是就是不能实现滚动条,
有哪位大哥了解这方面的帮小弟一忙。
代码:
    private File showfile;
    OleFrame oleFrame;
    OleClientSite clientSite;
    oleFrame = new OleFrame(composite, SWT.NONE);
    oleFrame.setLayout(new FillLayout());
    clientSite = new OleClientSite(oleFrame,          SWT.NULL,"Word.Document.8",showfile);
    clientsite.setEnabled(false);
    clientsite.doVerb(OLE.OLEIVERB_HIDE);
我试着在oleFrame = new OleFrame(composite, SWT.NONE);加了SWT.H_SCOLL
滚动条出现,但拖动滚动条,word文件不随着动。
我又试着在new OleClientSite(oleFrame,SWT.NULL,"Word.Document.8",showfile);
加了SWT.H_SCOLL,出现的情况也是一样。
作者: 深圳在漂移    时间: 2013-7-26 10:47
通过添加ScrolledComposite实现,可是这样子就把高度写死了。
ScrolledComposite composite = new ScrolledComposite(shell, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
composite.setBounds(0, 0, 760, 500);
composite.setLayoutData(gd);
OleFrame oleFrame=new OleFrame(composite,SWT.NONE);
composite.setContent(oleFrame);
composite.setMinSize(760,4);
oleFrame.setSize(760,18000);




欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) 黑马程序员IT技术论坛 X3.2