全屏显示 TOPMOST 窗口

发布于 2024-08-15 16:19:00 字数 627 浏览 5 评论 0 原文

我正在玩 Java 中的 JFrame。我希望它成为最上面的窗口,即始终位于顶部。 setAlwaysOnTop() 工作正常,但一旦我以全屏模式启动电影或游戏窗口,它就无法保持在顶部。

我玩弄了 JNI 和句柄。我的 JNI C 代码使用 SetWindowPos(),这似乎工作正常,直到我启动全屏应用程序。这是一个示例:

JNIEXPORT void JNICALL Java_Frame1_setWindowAlwaysOnTop
(JNIEnv *env, jclass obj, jint hwnd, jboolean flag)
{
  if (flag)
    SetWindowPos((HWND) hwnd,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);
  else
    SetWindowPos((HWND) hwnd,HWND_NOTOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);
  return;
}

我已经在谷歌上搜索了一段时间,我所确定的是全屏以独占模式运行,并且“暂停窗口系统,以便可以直接在屏幕上进行绘图”。

谁能建议一个解决方法?顺便提一句。我的 C 语言不是那么出色,所以放轻松..

谢谢! 达摩

I'm playing with a JFrame in Java. I want it to be the topmost window i.e. always on top. The setAlwaysOnTop() works fine, but as soon as I start a movie or a game-window in a full-screen mode then it fails to stay on top.

I played around with JNI and handles. My C code for JNI is using SetWindowPos() and this seems to be working OK until I start a full-screen app. Here's a sample:

JNIEXPORT void JNICALL Java_Frame1_setWindowAlwaysOnTop
(JNIEnv *env, jclass obj, jint hwnd, jboolean flag)
{
  if (flag)
    SetWindowPos((HWND) hwnd,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);
  else
    SetWindowPos((HWND) hwnd,HWND_NOTOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);
  return;
}

I've been googling for some time now and all I established is that the full-screen runs in an exclusive mode and "suspend the windowing system so that drawing can be done directly to the screen".

Can anyone suggest a workaround? BTW. my C is not that brilliant, so go easy..

Thanks!
Damo

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

念三年u 2024-08-22 16:19:00

“最顶层”仅在窗口环境中才有意义。

全屏游戏和电影通常会将模式切换为全屏独占模式。这意味着单个应用程序几乎可以完全控制视频 - 它可以更改分辨率,成为唯一显示的应用程序等。

当另一个应用程序全屏时,窗口应用程序即使在“最顶层”也不会显示独占模式,因为不再有可用的窗口概念。

"Topmost" only makes sense in a windowed environment.

Full-screen games and movies usually switch the mode to full-screen exclusive mode. That means that single application has pretty much total control over video - it can change the resolution, be the only application displayed, etc.

A windowed application, even in "topmost", isn't going to be displayed when another application has full screen exclusive mode, because there's no windowing concept available anymore.

小忆控 2024-08-22 16:19:00

“如何创建一个永远不会被任何其他窗口覆盖的窗口,甚至不会被其他最顶层的窗口覆盖?”

想象一下这是否可能,并想象一下如果有两个程序可以做到这一点。程序 A 创建一个“超级顶层”窗口,程序 B 也是如此。现在用户拖动这两个窗口,使它们重叠。会发生什么?你给自己创造了一个逻辑上的不可能。这两个窗口之一必须位于另一个窗口之上,这与想象中的“超级最顶层”功能相矛盾

来自:http://blogs.msdn.com/oldnewthing/archive/2005/06/07/426294.aspx :)

"How do I create a window that is never covered by any other windows, not even other topmost windows?"

Imagine if this were possible and imagine if two programs did this. Program A creates a window that is "super-topmost" and so does Program B. Now the user drags the two windows so that they overlap. What happens? You've created yourself a logical impossibility. One of those two windows must be above the other, contradicting the imaginary "super-topmost" feature

From : http://blogs.msdn.com/oldnewthing/archive/2005/06/07/426294.aspx :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文