作为一个宠物项目,我一直在尝试将 Aero Glass 效果集成到我的 SWT 应用程序中的概念。Łukasz Milewski 有一篇很棒的博客文章 http://www.milewski.ws/2009/02/vista-glass-in-swt-application/解释如何实现这一点,这几乎可以归结为:
final Display display = new Display();
final Shell shell = new Shell(display);
shell.setLayout(new FormLayout());
final MARGINS margins = new MARGINS();
margins.cyTopHeight = -1;
final Composite c = new Composite(shell, SWT.NORMAL);
c.setBackground(new Color(shell.getDisplay(), new RGB(0, 0, 0)));
final FormData fd = new FormData();
fd.top = new FormAttachment(0, 0);
fd.left = new FormAttachment(0, 0);
fd.right = new FormAttachment(100, 0);
fd.bottom = new FormAttachment(100, 0);
c.setLayoutData(fd);
OS.DwmExtendFrameIntoClientArea(shell.handle, margins);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
这工作得很好,直到你想添加一个控件。这导致黑色保持透明:
后续帖子 http://www.milewski.ws/2009/05/vista-glass-in-swt-application-continuation/也演示了如何执行此操作,但需要修改 SWT 库。 (至少,我相信是这样,因为私有 SWT 函数被重写为@Override
.)
如何避免控件变得透明?更好的是:我如何从透明度中受益(例如将图像放在上面like so http://www.milewski.ws/wp-content/uploads/2009/02/vista-glass-swt.png),但以合理的方式使用它?
重写的方法是“包私有”的。为了在没有编译时错误的情况下覆盖它们,您必须将类放入与超类相同的包中,即org.eclipse.swt
or org.eclipse.swt.widgets
包裹。您引用的博客实际上在最后提到了这个实现细节,所以我不知道,这是否真的回答了您的问题。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)