How to Make 'Always-On-Bottom'-Window

How to make 'always-on-bottom'-window

Warning It was suggested that you can accomplish this by calling SetParent and setting the window to be a child of the Desktop. If you do this, you cause the Win32 Window Manager to combine the input queue of the Desktop to your child window, this is a bad thing - Raymond Chen explains why.

Also, keep in mind that calling SetWindowPos with HWND_BOTTOM is incomplete. You need to do this whenever your window is changing zorder. Handle the WM_WINDOWPOSCHANGING event, look at SWP_NOZORDER for more info.

Pin window to desktop / Glue window to desktop / Always-on-bottom window

As @JonathanPotter pointed out, when hitting Windows + D or the Show Desktop button, the event WM_WINDOWPOSCHANGING gets fired, and the window gets moved to -32 000, -32 000 (its size also gets changed)

NOTE : a window without the style WS_MINIMIZEBOX seems not receiving WINDOWPOSCHANGING event when hitting Windows + D. Thus, no -32 000 coordinates detection in that case... Also noticed the same issue when using the ex style WS_EX_TOOLWINDOW (as this one gets rid of the minimize box, even if you set the style flag WS_MINIMIZEBOX).
Didn't find a solution for that case, so I'm sticking to an overlapped window.

To prevent this movement, just set the flags SWP_NOMOVE and SWP_NOSIZE on the WINDOWPOS structure passed in the lParam

So as a final result, to achieve the wanted behaviour (i.e always behind every other window but always in front of the desktop), the only needed code to add to the doc's sample is the following, placed in the window procedure WindowProc's switch statement :

EDIT : the best place to force the Z order with HWND_BOTTOM thus ensuring the window is always on bottom is also in the WM_WINDOWPOSCHANGING event. Indeed, calling SetWindowPos to force it in the WM_SIZE event when dragging the window over, as I was doing previously, causes some flickering on the window when resizing it, whereas no flickering occurs when setting directly the hwndInsertAfter property of the WINDOWPOS structure in WM_WINDOWPOSCHANGING.

case WM_WINDOWPOSCHANGING:
{
WINDOWPOS* pos = (WINDOWPOS*)lParam;
// Show desktop (Windows + D) results in the window moved to -32000, -32000 and size changed
if (pos->x == -32000) {
// Set the flags to prevent this and "survive" to the desktop toggle
pos->flags |= SWP_NOMOVE | SWP_NOSIZE;
}
// Also force the z order to ensure the window is always on bottom
pos->hwndInsertAfter = HWND_BOTTOM;
return 0;
}

Keep window always on bottom

According to this article, the wx.EVT_SET_FOCUS and wx.EVT_KILL_FOCUS events that I expect you were binding to are not fired on a panel or frame that contains widgets which themselves accept focus.

This answer suggests using the wx.EVT_ACTIVATE event on the frame to catch whenever the window is brought into the foreground or sent into the background. Using the event object you can determine whether or not the window is currently the foreground window.

The following makes an empty frame that will stay behind all other windows:

import wx

class MyFrame(wx.Frame):
def __init__(self, *args, **kwargs):
super(MyFrame, self).__init__(*args, **kwargs)
self.Bind(wx.EVT_ACTIVATE, self.on_focus)

def on_focus(self, evt):
self.Lower()

if __name__ == '__main__':
app = wx.App(False)
main_window = MyFrame(None)
main_window.Show()
app.MainLoop()

However, it appears that the wx.EVT_ACTIVATE event is not fired when the title bar of the window is clicked or when anything inside of the window is clicked after the window has gained focus this way. So, if you click on the title bar (not click and drag) you can make the window be on top and stay that way until the window loses focus. This does not exactly match what you are asking for but I think it is more of a feature than a bug.

how to make JFrame remain always on bottom?

If you don't want the user to interact with it just use setVisible(false) and set it true if/when needed

Make div stay at bottom of page's content all the time even when there are scrollbars

This is precisely what position: fixed was designed for:

#footer {
position: fixed;
bottom: 0;
width: 100%;
}

Here's the fiddle: http://jsfiddle.net/uw8f9/

How to make footer div always be at the bottom of page content

You need a set height into body,html tag.

Then you need a absolute position into #footer tag

For example like this:

html,
body {
margin:0;
padding:0;
height:100%;
}
#container {
min-height:100%;
position:relative;
}
#header {
background:#ff0;
padding:10px;
}
#body {
padding:10px;
padding-bottom:60px; /* adjust to footer height */
}
#footer {
position:absolute;
bottom:0;
width:100%;
height:60px; /* height of the footer */
background:#6cf;
}
<div id="container">
<div id="header"></div>
<div id="body"></div>
<div id="footer"></div>
</div>

How do I make a python window always be on bottom?

If you're talking about Tkinter, you can use:

 window.geometry('300x200-5+40')

Where the 300x200 is the size, and -5+40 is the positioning offsets.

Keeping HTML footer at the bottom of the window if page is short

Check out this site. He has a good tutorial on how to do this with css.

I copied his css just in case Matthew's site is taken down.

html,
body {
margin:0;
padding:0;
height:100%;
}
#container {
min-height:100%;
position:relative;
}
#header {
background:#ff0;
padding:10px;
}
#body {
padding:10px;
padding-bottom:60px; /* Height of the footer */
}
#footer {
position:absolute;
bottom:0;
width:100%;
height:60px; /* Height of the footer */
background:#6cf;
}

EDIT

Since the height of the footer is different from page to page, you could get the height of the footer and then adjust the #body padding-bottom with javascript. Here is an example using jquery.

$(function(){
$('#body').css('padding-bottom', $('#footer').height()+'px');
});


Related Topics



Leave a reply



Submit