我有一个ScrolledComposite,其内容正在被截断。我在谷歌上搜索过,并且意识到这在Windows上是一个众所周知的问题。
我唯一能找到的解决办法是使用canvas.scroll功能。
考虑到这个问题的年龄,我想知道是否有更好的解决办法?
谢谢!
(编辑:在撰写本报告时,链接是:http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet48.java?view=markup&content-type=text%2Fvnd.viewcvs-markup&revision=HEAD)
发布于 2011-02-22 17:18:21
(您发布的链接给出了一个400错误)
不确定我的问题是否相同,但我在ScrolledComposite中也遇到了截断问题。问题是,当我调整要滚动的组合大小时,滚动条变得可见时,控件没有考虑到滚动条占用的空间。为了解决这个问题,我在滚动组合中向我的调整大小监听器添加了一种递归代码:
在设置了内容组合的大小之后,请检查scrolled复合材料的滚动条(例如getVerticalBar())是否刚刚变得可见。如果是,请向侦听器发送新的调整大小事件。这是我的代码片段..。
public void handleEvent(Event event)
{
int newWidth = scrolledComposite.getSize().x;
boolean hasScroll = false;
ScrollBar scrollBar = scrolledComposite.getVerticalBar();
if (scrollBar.isVisible())
{
hasScroll = true;
newWidth -= scrolledComposite.getVerticalBar().getSize().x;
}
newWidth -= 8;
Point size = contentComposite.computeSize(newWidth, SWT.DEFAULT);
contentComposite.setSize(size);
int scroll_multiplier = size.y / 50;
scrollBar.setIncrement(scroll_multiplier);
/**
* If the scroll bar became visible because of the resize, then
* we actually need to resize it again, because of the scroll
* bar taking up some extra space.
*/
if (scrollBar.isVisible() && !hasScroll)
{
scrolledComposite.notifyListeners(SWT.Resize, null);
}
}希望这能有所帮助!
编辑:,哇,我没有注意到OP的日期。希望这最终能帮到别人.
https://stackoverflow.com/questions/3804433
复制相似问题