Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. "Always on top" attribute...

"Always on top" attribute...

Scheduled Pinned Locked Moved The Lounge
announcementquestion
29 Posts 17 Posters 4 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Sander RosselS Sander Rossel

    After I wrote all that even I was like TL;DR :laugh:

    dandy72 wrote:

    I know exactly how to do it, but the mystery in this case is how on God's Green Earth are random application windows getting that attribute when they don't (shouldn't?) even have code to do so. Like bits are flipping around randomly for no reason. Only, once it gets set, it never gets removed - unless I restart the app...

    if (!alwaysOnTopSet)
    {
    _alwaysOnTopSet = Random.Next(10) == 0; // 1 in 10 chance
    // Use _alwaysOnTopSet somewhere to make sure this always stays on top.
    // Also, never make it false once it's set to true.
    }

    I thought you knew exactly how to do this ;p

    Best, Sander Azure DevOps Succinctly (free eBook) Azure Serverless Succinctly (free eBook) Migrating Apps to the Cloud with Azure arrgh.js - Bringing LINQ to JavaScript

    D Offline
    D Offline
    dandy72
    wrote on last edited by
    #11

    Smartass. Have a 5! :-)

    1 Reply Last reply
    0
    • G GuyThiebaut

      There's been a big change in how UIs behave which is that previously the user had control and would not be interrupted by the OS, processes or notifications - the user always had focus. Nowadays, the user is just seen as one process and that process can be interrupted, have notifications pop up over a cursor or mouse pointer and be interrupted at any time - the user has become the slave to the machine.

      “That which can be asserted without evidence, can be dismissed without evidence.”

      ― Christopher Hitchens

      T Offline
      T Offline
      trønderen
      wrote on last edited by
      #12

      GuyThiebaut wrote:

      the user had control and would not be interrupted by the OS, processes or notifications

      I have been using tools that frequently created error reporting dialog windows consistently at the bottom of the window stack - it could even be obscured by its own main window! The dialogs were modal, blocking the application from execution, until by accident or luck moved other windows to discover that there was a new window down at the bottom demanding my attention and action. It really was a pain in the lower part of the back. I hated it. If an application requires me to take an action for it to continue, it should call my attention to it, one way or the other. Equally bad is if the notification or error dialog pops up a large, centered window, immediately grabbing keyboard, mouse and other inputs in the middle of a word that I am typing, or the dragging of an object. There is a middle ground, e.g. a flashing icon in the taskbar. But I prefer a dialog on top that does not grab focus (and preferably not centered) to a window at the bottom of the window stack. The ideal would be an option to put the window as the second one from the top, so that it won't obscure the one currently having focus, with the default/automatic placement algorithm ensuring that a significant part of it sticks out from under the currently active window.

      1 Reply Last reply
      0
      • D dandy72

        Decades ago MS added an "always on top" attribute you could give to a window your app creates so you could have a window that was always floating on top of everything else. If you dragged another window over that area, you could see the window being dragged slide "underneath" it rather than on top of it as you would otherwise ordinarily expect. These days you rarely see apps using this attribute, but I don't believe there's anything in more recent versions of Windows to prevent you from using it. For the past couple of years (and it's been this long before I decided to ask, just now) I've noticed a few apps that should never have this attribute, or at least have never presented any option to make it top-most, seemingly *randomly* get this attribute out of nowhere, and it stays that way until you close the app and restart it. I have an old version of a news reader (as in Usenet) that does this every once in a while, and I've also seen remote desktop sessions do it also. Once the window somehow decides it's going to always be on top, I can't bring other windows in front. None of the apps I've seen exhibit this behavior have any option to turn this on or off, and I can't imagine any sort of criteria where code in an app might turn on the always-on-top attribute. Am I speaking total non-sense, or has anyone else ever seen this? [Edit] I've done a quick google search, and while there are apps that apparently people use to make any app top-most, I absolutely, positively, have never downloaded such apps...and as far as I know there's no magic, secret key combination built into Windows to do that either.

        D Offline
        D Offline
        David ONeil
        wrote on last edited by
        #13

        Here is an AutoHotKey script to toggle topmost. It may be able to disable the feature for you if you use AHK:

        ; possibly from http://www.howtogeek.com/howto/44915/how-to-change-window-transparency-in-windows-7/
        !`:: ;Alt `
        WinGet, currentWindow, ID, A
        WinGet, ExStyle, ExStyle, ahk_id %currentWindow%
        if (ExStyle & 0x8) { ; 0x8 is WS_EX_TOPMOST.
        Winset, AlwaysOnTop, off, ahk_id %currentWindow%
        SplashImage,, x0 y0 b fs12, OFF always on top.
        Sleep, 1500
        SplashImage, Off
        }
        else {
        WinSet, AlwaysOnTop, on, ahk_id %currentWindow%
        SplashImage,,x0 y0 b fs12, ON always on top.
        Sleep, 1500
        SplashImage, Off
        }
        return

        Our Forgotten Astronomy | Object Oriented Programming with C++ | Wordle solver

        1 Reply Last reply
        0
        • D dandy72

          Yes, I have the technical understanding and have created such apps decades ago. What I'm saying is that the attribute "randomly" gets applied to applications for no apparent reason, when said app had already been running for many minutes/hours/days.

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #14

          I have apps that run for weeks and have never seen that occur.

          D 1 Reply Last reply
          0
          • E englebart

            [Original] Some of those window attributes could be tied into the window class which would make it immutable, but I have seen apps that allow it to be toggled. On a hunch, I googled if there is a system hot key for this and some post mentions Ctrl + Spacebar as a toggle. Which is an oft used hot key in my IDEs. I will have to try it later. [Update follows] It looks like window class was for old 32 bit API from another poster. Different poster has/had good good info on SetWindowPos(ition) API which is newer from Vista+. I think the hot key was app specific, I could not get it to work with Notepad. (Notepad could still be win32?) I put a newer post at the bottom with a better reference.

            P Offline
            P Offline
            Paul Sanders the other one
            wrote on last edited by
            #15

            > Some of those window attributes could be tied into the window class There is no such [window class style](https://learn.microsoft.com/en-us/windows/win32/winmsg/window-class-styles). You do it via [SetWindowPos](https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setwindowpos) (by setting `hWndInsertAfter` to `HWND_TOPMOST`). You

            Paul Sanders. If I had more time, I would have written a shorter letter - Blaise Pascal. Some of my best work is in the undo buffer.

            1 Reply Last reply
            0
            • D dandy72

              Decades ago MS added an "always on top" attribute you could give to a window your app creates so you could have a window that was always floating on top of everything else. If you dragged another window over that area, you could see the window being dragged slide "underneath" it rather than on top of it as you would otherwise ordinarily expect. These days you rarely see apps using this attribute, but I don't believe there's anything in more recent versions of Windows to prevent you from using it. For the past couple of years (and it's been this long before I decided to ask, just now) I've noticed a few apps that should never have this attribute, or at least have never presented any option to make it top-most, seemingly *randomly* get this attribute out of nowhere, and it stays that way until you close the app and restart it. I have an old version of a news reader (as in Usenet) that does this every once in a while, and I've also seen remote desktop sessions do it also. Once the window somehow decides it's going to always be on top, I can't bring other windows in front. None of the apps I've seen exhibit this behavior have any option to turn this on or off, and I can't imagine any sort of criteria where code in an app might turn on the always-on-top attribute. Am I speaking total non-sense, or has anyone else ever seen this? [Edit] I've done a quick google search, and while there are apps that apparently people use to make any app top-most, I absolutely, positively, have never downloaded such apps...and as far as I know there's no magic, secret key combination built into Windows to do that either.

              M Offline
              M Offline
              MikeCO10
              wrote on last edited by
              #16

              I can't say I've seen any apps that force the always on top lately, with the possible exception of some splash screens on opening. I'm thinking I've seen that with a couple opening from "show hidden icons" menu on the task bar. But they don't maintain it once they load. Some errant App code could set it or something wonky in a focus/modal call in an older program? Back in the day I used "always on top" a couple of times, but it usually turned out to be a nightmare. It's like setting the "unintended consequences" attribute :laugh:

              1 Reply Last reply
              0
              • D dandy72

                Decades ago MS added an "always on top" attribute you could give to a window your app creates so you could have a window that was always floating on top of everything else. If you dragged another window over that area, you could see the window being dragged slide "underneath" it rather than on top of it as you would otherwise ordinarily expect. These days you rarely see apps using this attribute, but I don't believe there's anything in more recent versions of Windows to prevent you from using it. For the past couple of years (and it's been this long before I decided to ask, just now) I've noticed a few apps that should never have this attribute, or at least have never presented any option to make it top-most, seemingly *randomly* get this attribute out of nowhere, and it stays that way until you close the app and restart it. I have an old version of a news reader (as in Usenet) that does this every once in a while, and I've also seen remote desktop sessions do it also. Once the window somehow decides it's going to always be on top, I can't bring other windows in front. None of the apps I've seen exhibit this behavior have any option to turn this on or off, and I can't imagine any sort of criteria where code in an app might turn on the always-on-top attribute. Am I speaking total non-sense, or has anyone else ever seen this? [Edit] I've done a quick google search, and while there are apps that apparently people use to make any app top-most, I absolutely, positively, have never downloaded such apps...and as far as I know there's no magic, secret key combination built into Windows to do that either.

                D Offline
                D Offline
                darktrick544
                wrote on last edited by
                #17

                In a couple little utility apps I've made, I have a menu selection for this. When I do offer that option, I also offer one to make the window transparent when not top in the z-order, and a transparency percent. So even though it could be stay on top, you can still see thru it. It has it's uses.

                1 Reply Last reply
                0
                • D dandy72

                  Decades ago MS added an "always on top" attribute you could give to a window your app creates so you could have a window that was always floating on top of everything else. If you dragged another window over that area, you could see the window being dragged slide "underneath" it rather than on top of it as you would otherwise ordinarily expect. These days you rarely see apps using this attribute, but I don't believe there's anything in more recent versions of Windows to prevent you from using it. For the past couple of years (and it's been this long before I decided to ask, just now) I've noticed a few apps that should never have this attribute, or at least have never presented any option to make it top-most, seemingly *randomly* get this attribute out of nowhere, and it stays that way until you close the app and restart it. I have an old version of a news reader (as in Usenet) that does this every once in a while, and I've also seen remote desktop sessions do it also. Once the window somehow decides it's going to always be on top, I can't bring other windows in front. None of the apps I've seen exhibit this behavior have any option to turn this on or off, and I can't imagine any sort of criteria where code in an app might turn on the always-on-top attribute. Am I speaking total non-sense, or has anyone else ever seen this? [Edit] I've done a quick google search, and while there are apps that apparently people use to make any app top-most, I absolutely, positively, have never downloaded such apps...and as far as I know there's no magic, secret key combination built into Windows to do that either.

                  G Offline
                  G Offline
                  Gary Wheeler
                  wrote on last edited by
                  #18

                  I have a feeling this is not a bug in the topmost window handling in the application, but in Windows' management of which application it decides is the foreground app. There have been numerous changes to the foreground decision logic during Windows 7, 10, and 11. Some of the changes were hailed by Microsoft that they gave the user more control, and disallowed applications from the annoying tendency of grabbing the foreground. I also have the feeling some of these changes have been 'internal' in order to handle task bar notification balloons and such. There are also problems with legacy API's (for example, some message box options) that assume foreground behaviors that are no longer certain. TL;DR - It's complicated, from some perspectives it's broke, and they ain't gonna fix it.

                  Software Zen: delete this;

                  D 1 Reply Last reply
                  0
                  • L Lost User

                    I have apps that run for weeks and have never seen that occur.

                    D Offline
                    D Offline
                    dandy72
                    wrote on last edited by
                    #19

                    For sure. There's no reason whatsoever an app should suddenly start doing this no matter how long it's been running for.

                    1 Reply Last reply
                    0
                    • D dandy72

                      Decades ago MS added an "always on top" attribute you could give to a window your app creates so you could have a window that was always floating on top of everything else. If you dragged another window over that area, you could see the window being dragged slide "underneath" it rather than on top of it as you would otherwise ordinarily expect. These days you rarely see apps using this attribute, but I don't believe there's anything in more recent versions of Windows to prevent you from using it. For the past couple of years (and it's been this long before I decided to ask, just now) I've noticed a few apps that should never have this attribute, or at least have never presented any option to make it top-most, seemingly *randomly* get this attribute out of nowhere, and it stays that way until you close the app and restart it. I have an old version of a news reader (as in Usenet) that does this every once in a while, and I've also seen remote desktop sessions do it also. Once the window somehow decides it's going to always be on top, I can't bring other windows in front. None of the apps I've seen exhibit this behavior have any option to turn this on or off, and I can't imagine any sort of criteria where code in an app might turn on the always-on-top attribute. Am I speaking total non-sense, or has anyone else ever seen this? [Edit] I've done a quick google search, and while there are apps that apparently people use to make any app top-most, I absolutely, positively, have never downloaded such apps...and as far as I know there's no magic, secret key combination built into Windows to do that either.

                      D Offline
                      D Offline
                      decaffeinatedMonkey
                      wrote on last edited by
                      #20

                      Windows PowerToys has a feature to toggle any app to become top-most. It would be cool for that feature to notify you which apps are already top-most, and flip that switch off if they try to force being top-most.

                      D M 2 Replies Last reply
                      0
                      • G Gary Wheeler

                        I have a feeling this is not a bug in the topmost window handling in the application, but in Windows' management of which application it decides is the foreground app. There have been numerous changes to the foreground decision logic during Windows 7, 10, and 11. Some of the changes were hailed by Microsoft that they gave the user more control, and disallowed applications from the annoying tendency of grabbing the foreground. I also have the feeling some of these changes have been 'internal' in order to handle task bar notification balloons and such. There are also problems with legacy API's (for example, some message box options) that assume foreground behaviors that are no longer certain. TL;DR - It's complicated, from some perspectives it's broke, and they ain't gonna fix it.

                        Software Zen: delete this;

                        D Offline
                        D Offline
                        dandy72
                        wrote on last edited by
                        #21

                        This is the closest thing to a possible explanation as I've seen throughout this entire thread; seems like some people have missed my point, or intentionally ignored it.

                        Gary Wheeler wrote:

                        TL;DR - It's complicated, from some perspectives it's broke, and they ain't gonna fix it.

                        No feature is ever so simple that MS can't find a way to complicate it to the point where it becomes buggy.

                        1 Reply Last reply
                        0
                        • D decaffeinatedMonkey

                          Windows PowerToys has a feature to toggle any app to become top-most. It would be cool for that feature to notify you which apps are already top-most, and flip that switch off if they try to force being top-most.

                          D Offline
                          D Offline
                          dandy72
                          wrote on last edited by
                          #22

                          That's an intriguing idea. If it was such a big hassle, I just might throw something together to periodically pool all windows and look which has the attribute, and log when the topmost flag gets assigned to a window - that might help narrow down what actually triggers it. But, it's still so rare I don't think I'd invest the time in doing that. Every time I've seen this happen, closing/restarting the app is all that's needed to get the window behaving normally again, and I can certainly live with that.

                          1 Reply Last reply
                          0
                          • D decaffeinatedMonkey

                            Windows PowerToys has a feature to toggle any app to become top-most. It would be cool for that feature to notify you which apps are already top-most, and flip that switch off if they try to force being top-most.

                            M Offline
                            M Offline
                            maze3
                            wrote on last edited by
                            #23

                            POWER TOOLS 💪 POWER, FLEX came to say same. And Media Player Classic has 3 options, for all the uhm "home movies" I watch. 😶 always on top on top while playing 👍 off

                            1 Reply Last reply
                            0
                            • D dandy72

                              Decades ago MS added an "always on top" attribute you could give to a window your app creates so you could have a window that was always floating on top of everything else. If you dragged another window over that area, you could see the window being dragged slide "underneath" it rather than on top of it as you would otherwise ordinarily expect. These days you rarely see apps using this attribute, but I don't believe there's anything in more recent versions of Windows to prevent you from using it. For the past couple of years (and it's been this long before I decided to ask, just now) I've noticed a few apps that should never have this attribute, or at least have never presented any option to make it top-most, seemingly *randomly* get this attribute out of nowhere, and it stays that way until you close the app and restart it. I have an old version of a news reader (as in Usenet) that does this every once in a while, and I've also seen remote desktop sessions do it also. Once the window somehow decides it's going to always be on top, I can't bring other windows in front. None of the apps I've seen exhibit this behavior have any option to turn this on or off, and I can't imagine any sort of criteria where code in an app might turn on the always-on-top attribute. Am I speaking total non-sense, or has anyone else ever seen this? [Edit] I've done a quick google search, and while there are apps that apparently people use to make any app top-most, I absolutely, positively, have never downloaded such apps...and as far as I know there's no magic, secret key combination built into Windows to do that either.

                              B Offline
                              B Offline
                              Bruce Patin
                              wrote on last edited by
                              #24

                              No, I have not seen windows forcibly moved underneath an "always on top" window, but I have often waited for some function in an app to be done with a spinning GIF indicating that it is working on the task, then several minutes later, maybe after I have given up and aborted the operation, find that there was a required dialog to continue that process underneath the main window that I was waiting on. That's one case where such dialogs should be "always on top", so I don't miss them.

                              D 1 Reply Last reply
                              0
                              • D dandy72

                                Decades ago MS added an "always on top" attribute you could give to a window your app creates so you could have a window that was always floating on top of everything else. If you dragged another window over that area, you could see the window being dragged slide "underneath" it rather than on top of it as you would otherwise ordinarily expect. These days you rarely see apps using this attribute, but I don't believe there's anything in more recent versions of Windows to prevent you from using it. For the past couple of years (and it's been this long before I decided to ask, just now) I've noticed a few apps that should never have this attribute, or at least have never presented any option to make it top-most, seemingly *randomly* get this attribute out of nowhere, and it stays that way until you close the app and restart it. I have an old version of a news reader (as in Usenet) that does this every once in a while, and I've also seen remote desktop sessions do it also. Once the window somehow decides it's going to always be on top, I can't bring other windows in front. None of the apps I've seen exhibit this behavior have any option to turn this on or off, and I can't imagine any sort of criteria where code in an app might turn on the always-on-top attribute. Am I speaking total non-sense, or has anyone else ever seen this? [Edit] I've done a quick google search, and while there are apps that apparently people use to make any app top-most, I absolutely, positively, have never downloaded such apps...and as far as I know there's no magic, secret key combination built into Windows to do that either.

                                M Offline
                                M Offline
                                Matthew Barnett
                                wrote on last edited by
                                #25

                                I've recently started using "EPG Centre", an app that reads the EPG that's broadcast by Freeview. Its progress bar is always on top. It takes several minutes to read the EPG, so I start it and then let it run in the background, but the progress bar stays on top, for no reason.

                                D 1 Reply Last reply
                                0
                                • B Bruce Patin

                                  No, I have not seen windows forcibly moved underneath an "always on top" window, but I have often waited for some function in an app to be done with a spinning GIF indicating that it is working on the task, then several minutes later, maybe after I have given up and aborted the operation, find that there was a required dialog to continue that process underneath the main window that I was waiting on. That's one case where such dialogs should be "always on top", so I don't miss them.

                                  D Offline
                                  D Offline
                                  dandy72
                                  wrote on last edited by
                                  #26

                                  MessageBox.Show( "blah" );

                                  ...with no parent param specified will often result in that sort of thing. If you've switched to another app before the popup appears, giving focus back to the app will NOT bring the popup back from behind whatever it's hiding. Set your message box parents, people!!

                                  1 Reply Last reply
                                  0
                                  • M Matthew Barnett

                                    I've recently started using "EPG Centre", an app that reads the EPG that's broadcast by Freeview. Its progress bar is always on top. It takes several minutes to read the EPG, so I start it and then let it run in the background, but the progress bar stays on top, for no reason.

                                    D Offline
                                    D Offline
                                    dandy72
                                    wrote on last edited by
                                    #27

                                    Sounds like in this case, it was intentionally designed this way. Clearly these guys think they're so important the progress bar must *always* remain visible...

                                    1 Reply Last reply
                                    0
                                    • D dandy72

                                      Decades ago MS added an "always on top" attribute you could give to a window your app creates so you could have a window that was always floating on top of everything else. If you dragged another window over that area, you could see the window being dragged slide "underneath" it rather than on top of it as you would otherwise ordinarily expect. These days you rarely see apps using this attribute, but I don't believe there's anything in more recent versions of Windows to prevent you from using it. For the past couple of years (and it's been this long before I decided to ask, just now) I've noticed a few apps that should never have this attribute, or at least have never presented any option to make it top-most, seemingly *randomly* get this attribute out of nowhere, and it stays that way until you close the app and restart it. I have an old version of a news reader (as in Usenet) that does this every once in a while, and I've also seen remote desktop sessions do it also. Once the window somehow decides it's going to always be on top, I can't bring other windows in front. None of the apps I've seen exhibit this behavior have any option to turn this on or off, and I can't imagine any sort of criteria where code in an app might turn on the always-on-top attribute. Am I speaking total non-sense, or has anyone else ever seen this? [Edit] I've done a quick google search, and while there are apps that apparently people use to make any app top-most, I absolutely, positively, have never downloaded such apps...and as far as I know there's no magic, secret key combination built into Windows to do that either.

                                      E Offline
                                      E Offline
                                      englebart
                                      wrote on last edited by
                                      #28

                                      I found this on another site that seems to line up with what you are seeing, especially if you use the WinLogo + D, or task bar "Show the desktop" to toggle all windows away, then back. There are some possible work arounds mentioned like Ctrl+Alt+Esc might help reset it. [https://superuser.com/questions/269415/show-desktop-sometimes-sets-a-window-to-always-on-top\](https://superuser.com/questions/269415/show-desktop-sometimes-sets-a-window-to-always-on-top)

                                      1 Reply Last reply
                                      0
                                      • D dandy72

                                        Decades ago MS added an "always on top" attribute you could give to a window your app creates so you could have a window that was always floating on top of everything else. If you dragged another window over that area, you could see the window being dragged slide "underneath" it rather than on top of it as you would otherwise ordinarily expect. These days you rarely see apps using this attribute, but I don't believe there's anything in more recent versions of Windows to prevent you from using it. For the past couple of years (and it's been this long before I decided to ask, just now) I've noticed a few apps that should never have this attribute, or at least have never presented any option to make it top-most, seemingly *randomly* get this attribute out of nowhere, and it stays that way until you close the app and restart it. I have an old version of a news reader (as in Usenet) that does this every once in a while, and I've also seen remote desktop sessions do it also. Once the window somehow decides it's going to always be on top, I can't bring other windows in front. None of the apps I've seen exhibit this behavior have any option to turn this on or off, and I can't imagine any sort of criteria where code in an app might turn on the always-on-top attribute. Am I speaking total non-sense, or has anyone else ever seen this? [Edit] I've done a quick google search, and while there are apps that apparently people use to make any app top-most, I absolutely, positively, have never downloaded such apps...and as far as I know there's no magic, secret key combination built into Windows to do that either.

                                        S Offline
                                        S Offline
                                        Shmoken99
                                        wrote on last edited by
                                        #29

                                        Managed code or unmanaged code? Could a memory leak or uninitialized pointer flip the always on top setting for a long running app? Even managed code can be leaky, but usually you just run out of memory.

                                        1 Reply Last reply
                                        0
                                        Reply
                                        • Reply as topic
                                        Log in to reply
                                        • Oldest to Newest
                                        • Newest to Oldest
                                        • Most Votes


                                        • Login

                                        • Don't have an account? Register

                                        • Login or register to search.
                                        • First post
                                          Last post
                                        0
                                        • Categories
                                        • Recent
                                        • Tags
                                        • Popular
                                        • World
                                        • Users
                                        • Groups