我正在玩 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
发布评论
评论(2)
“最顶层”仅在窗口环境中才有意义。
全屏游戏和电影通常会将模式切换为全屏独占模式。这意味着单个应用程序几乎可以完全控制视频 - 它可以更改分辨率,成为唯一显示的应用程序等。
当另一个应用程序全屏时,窗口应用程序即使在“最顶层”也不会显示独占模式,因为不再有可用的窗口概念。
"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.
来自:http://blogs.msdn.com/oldnewthing/archive/2005/06/07/426294.aspx :)
From : http://blogs.msdn.com/oldnewthing/archive/2005/06/07/426294.aspx :)