Keep Window Always on Top

Keep browser window always on top for a valid use case

I don't think what you're asking for exists, no.

The closest that I can think of is the fullscreen API, but that won't work for your use case — it sounds like you want other windows to be visible, just not on top.

I think you'll have to use user training to get the best results you can, telling them to be sure that their face is visible and not behind some other window.

Visual Basic .Net, keep windows on top of other on-top windows

Apparently the solution was pretty simple.

I was afraid of side-effects, but the solution I applied works perfectly.

I added a timer, enabled it, and every tick it simply does:

me.Topmost = true

If I now click the taskbar, the program is obviously pushed to the back, but every 100ms when the timer ticks, the program is automatically put back on top without the app actually receiving focus.

Keep one window always on top of another programatically

Make the window you wish to be on top be owned by the other window. An owned window is always above its owner. The documentation says:

Owned Windows

An overlapped or pop-up window can be owned by another overlapped or
pop-up window. Being owned places several constraints on a window.

  • An owned window is always above its owner in the z-order.
  • The system automatically destroys an owned window when its owner is destroyed.
  • An owned window is hidden when its owner is minimized.

Only an overlapped or pop-up window can be an owner window; a child
window cannot be an owner window. An application creates an owned
window by specifying the owner's window handle as the hwndParent
parameter of CreateWindowEx when it creates a window with the
WS_OVERLAPPED or WS_POPUP style. The hwndParent parameter must
identify an overlapped or pop-up window. If hwndParent identifies a
child window, the system assigns ownership to the top-level parent
window of the child window. After creating an owned window, an
application cannot transfer ownership of the window to another window.

Dialog boxes and message boxes are owned windows by default. An
application specifies the owner window when calling a function that
creates a dialog box or message box.

An application can use the GetWindow function with the GW_OWNER flag
to retrieve a handle to a window's owner.

So, specify the owner of a window with the hWndParent arguments of CreateWindowEx. The documentation is a bit hard to follow. It says:

hWndParent [in, optional]

A handle to the parent or owner window of the window being created. To create a child window or an owned window, supply a valid window handle. This parameter is optional for pop-up windows.

What this is getting at is that the parameter is overloaded. For pop-up windows, this parameter specifies the owner. And when you wish to create an unowned window pass NULL. That's what it means by the parameter being optional for pop-up windows. For child windows, you pass the parent of the window in this parameter.

Now, in your case, you want to create an owned pop-up window, and so pass the owner in this parameter.

How to keep window always on top

It should be possible by setting the Focus on window, from OnFocusLost event handler.

How to make application window stay on top in pyqt5?

Assuming the rest of your code is good, change the following line of code:

self.setWindowFlags(Qt.WindowStaysOnTopHint)

to the following line of code:

self.setWindowFlags(QtCore.Qt.Window | QtCore.Qt.CustomizeWindowHint | Qt.WindowStaysOnTopHint)

Link to an answer explaining why the code change above is required for the Qt.WindowStaysOnTop flag to work.

QML on Windows: make the window to stay on top

As you have posted: If the window is created from the foreground process, we will just make sure, that our process is the foreground process before we create the window.

import QtQuick 2.7
import QtQuick.Window 2.2

Item {
id: root

Component { // Like a splash screen: Claim to be foreground process,
// then create main window.
id: winInit
Window {
flags: Qt.WindowStaysOnTopHint
width: 1
height: 1
Component.onCompleted: {
requestActivate()
mainWin.createObject(root)
}
}
}

Component {
id: mainWin
Window {
flags: Qt.WindowStaysOnTopHint
width: 100
height: 100
visible: true
}
}

Component.onCompleted: {
var w1 = winInit.createObject(null)
w1.destroy()
}
}

Processing, keep window on top/ overlay

If you're using Processing 3 (and you should be), then you should no longer use the frame variable- the other answer doesn't seem to do anything in Processing 3.

Instead, use the surface variable:

void setup(){
size(200, 200);
surface.setAlwaysOnTop(true);
}

void draw(){
background(0);
ellipse(mouseX, mouseY, 10, 10);
}

More info on the changes made in Processing 3 can be found here and here.



Related Topics



Leave a reply



Submit