【问题标题】:Draw overlay over multiple monitors在多个显示器上绘制叠加层
【发布时间】:2016-04-18 15:43:49
【问题描述】:

我想在多个显示器上绘制叠加层,它应该覆盖每个任务栏,基本上是每个元素。我在 4.5.2 版本中使用 SWT。

到目前为止我做了什么?

shell = new Shell(display.getActiveShell(), SWT.ON_TOP | SWT.DOUBLE_BUFFERED);
shell.setBounds(display.getBounds());

这个解决方案在我的 Debian (stretch) 上完美运行。 windows有问题,我测试过windows 10,它会绘制覆盖,但是任务栏在顶部。

我考虑过在 N 个显示器上激活全屏的 N 个分隔的 shell,但我认为不可能在多个 shell 上激活全屏。

有人知道吗?也许我应该尝试使用其他库?

【问题讨论】:

    标签: java swt desktop-application


    【解决方案1】:

    总吐球,但是

    Rectangle rect = new Rectangle(0, 0, 0, 0);
    Stream.of(shell.getDisplay().getMonitors()).map(Monitor::getBounds).forEach(p->rect.add(p));
    shell.setBounds(rect);
    

    【讨论】:

    • 我的问题不是显示范围,因为它会绘制覆盖,但 win10 上的任务栏会覆盖它:/ 我不知道是 swt 还是 windows 的限制,无论如何感谢您的帮助跨度>
    • Display d = Display.getDefault(); final Shell s1 = new Shell(Display.getCurrent(), SWT.ON_TOP | SWT.DOUBLE_BUFFERED); s1.setBounds(d.getBounds()); s1.setLayout(new FillLayout()); Button b = new Button(s1, SWT.NONE); b.setText("getBounds()"); b.addListener(SWT.Selection, e -> { s1.dispose(); }); s1.open(); while (!s1.isDisposed()) { if (!d.readAndDispatch()) { d.sleep(); } } 这适用于运行 64 位 JRE 1.8.0_77 的 Windows 7。覆盖整个屏幕,包括任务栏
    • @pretzalcoatl OPs 原始解决方案在 Windows 7 上也可以正常工作。 Windows 10 似乎是这里的问题。
    • @Baz 直接调用 display.getBounds() 或累积 Monitor.getBounds() 在 Windows 10 上的单个监视器上都可以正常工作。奇怪。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-03-12
    • 2019-04-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多