你如何强迫java swt程序“将自己移到前台”? [英] How do you force a java swt program to "move itself to the foreground"?

查看:183
本文介绍了你如何强迫java swt程序“将自己移到前台”?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前有了swt,我有时想让一个程序随意地到达前台(就像闹钟一样)。

Currently with swt, I sometimes want a program to arbitrarily come to the foreground (like an alarm clock might).

通常以下作品(jruby):

Typically the following works (jruby):

@shell.setMinimized(false)
@shell.forceActive

如果它被最小化,这会将shell带到前面。

This brings the shell to the front if it was minimized.

在任何地方创建一个新shell时间也会把(新的shell)带到前面。

Creating a new shell at any time also brings the (new shell) to the front.

到目前为止,如果shell 最小化,那么上面这么好代码只是闪烁(闪烁)任务栏中的应用程序图标。实际上,当你第一次运行它时,它会把它带到前面。之后,它只是在任务栏中闪烁。那是窗户。在Linux上它似乎只在任务栏中闪烁(默认为ubuntu)。

So far so good, however, if the shell is not minimized, the above code just flashes (blinks) the app's icon in the taskbar. Well actually the first time you run it, it brings it to the front. After that, it just blinks in the taskbar. That's windows. On Linux it appears to only blink in the taskbar (ubuntu default).

是否有人知道跨平台的方式让应用程序出现在前面,在swt中?

Does anybody know of a cross platform way of getting the app to come to the front, in swt?

似乎没有强制使用forceActive setActive setMinimized(false)setFocus forceFocus和setVisible可以完成这件事。

It seems that no incantation of forceActive setActive setMinimized(false) setFocus forceFocus and setVisible can accomplish this thing.

我很确定它是可能的(至少在windows中),就像E文本编辑器那样。嗯,这不是swt,但至少还有其他一些应用已经知道这样做了。

I'm pretty sure it is possible (at least in windows), as the E Text Editor does it. Well, that's not swt, but at least some other apps have been known to do it.

我想也许这是 swt bug 192036

非常感谢。

相关:

  • How to bring a window to the front?
  • Opening a Shell
  • Keep window in foreground (even if it loses focus)
  • Bug 244597 - Cannot activate shell programatically on gtk
  • Need to bring application to foreground on Windows
  • How to bring a window to the front? this swing example might be some type of clue, too...

推荐答案

http://github.com/rdp/redcar/commit/d7dfeb8e77f13e5596b11df3027da236f23c83f0

显示我是如何在Windows中完成的,无论如何(使用ffi)。

shows how I did it in windows, anyway (using ffi).

一些有用的技巧可能

添加'睡眠0.1 '在BringToFront.SetForegroundWindow(想要)
之后调用(希望这个实际上不是必需的)。

add a 'sleep 0.1' after the BringToFront.SetForegroundWindow(wanted) call (hopefully this one isn't actually necessary).

在之后添加一个shell.set_active ,你已将窗口带到前台。由于某种原因,forceActive不会调用setActive。

add a shell.set_active after you have brought the window to the foreground. For some reason forceActive doesn't call setActive.

请注意,setActive会执行user32.dll BringWindowToTop调用,并且需要在分离线程输入之前完成。

NB that setActive does a user32.dll BringWindowToTop call, and needs to be done before you detach thread input.

另请注意,如果您可以按照正确的顺序进行调用,则可能根本不需要使用线程输入hack(?)

Note also that it appears if you can do you calls in the right order you may not need to use the thread input hack at all (?)

http://betterlogic.com/roger/?p=2950

(包含几个关于如何实际执行此操作的好提示正确

(contains several good hints on how to actually do this right)

在Linux上,forceActive 工作 - 但只有在你移动到另外几个窗口之后,它才会在那之后(仅)在任务栏中闪烁。猜swt bug。 [1]

On Linux, forceActive does work--but only until you move to another few windows,, then it blinks in the taskbar after that (only). Guessing swt bug. [1]

还相关:

如何将窗口移到前面?

http://github.com/jarmo/win32screenshot/ blob / master / lib / win32 / screenshot / bitmap_maker.rb#L110 set_foreground似乎适用于两者 xp和windows 7

http://github.com/jarmo/win32screenshot/blob/master/lib/win32/screenshot/bitmap_maker.rb#L110 "set_foreground" which seems to work with both xp and windows 7

[1] 需要将应用程序带到Windows的前台 https://bugs.eclipse.org/bugs/show_bug。 cgi?id = 303710

这篇关于你如何强迫java swt程序“将自己移到前台”?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆