Question

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

Was it helpful?

Solution

"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.

OTHER TIPS

"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 :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top