Google Chrome: Always On Top Bug

In the case of Chrome, this is a known issue : Chrome window always-on-top behavior

A quick fix for this problem is to select the Chrome Window and press F11 twice.


To disable this you have to hit

ALT + Space + C

alt+space+c

After pressing these buttons Google chrome browser will close automatically. Then start again the Google chrome browser.

The problem will be solve for ever :)


What does it look like?

There is only one behavior close to that problem and that would be the Always On Top behavior.
Some piece of code, perhaps from the program itself might be changing the property of your window...

How is a window set to be "Always On Top"?

How To Create a Form That Always Stays on Top shows us that SetWindowPos is called with the second parameter set to HWND_TOPMOST, this immediately places it on top and keeps it that way.

After a quick Google, this result reveals User32.dll to be the owner of this function.

Who sets my window "Always On Top"?

Now that we have the knowledge what function is called, we will want to know when that function is called. This will require us to make stack traces and analyze them, while Windows Performance Toolkit can do this we can be very happy that Rohitab Batra has written the awesome Api Monitor.

Sorry, but this is hard homework:

  • Download API Monitor and install it.
  • Open API Monitor as an administrator, if you have 64 bit, you need to do this twice.
  • Make sure that nothing is checked in API Capture Filter at the left side.
  • In the same place, change All Modules at the top of that Dialog to User32.dll.
  • Go to

    Windows Application UI Development > Windows and Messages > Windows
    

    and then

    User32.dll > SetWindowPos
    

Now, you will want to hook some processes. Word of caution: Sort by PID and do not hook into winlogon.exe or anything that has a lower PID than that, if you do so you will either hang or crash your system. You might experience this behavior with other processes too, but it's kind of like a trial and error to see which ones you can hook. So:

  • Sort by PID, and hook everything that's newer than winlogon.exe.
  • If everything goes well, you can look through the threads in the Hooked Process dialog.
  • Look for an API call that looks like this:

    SetWindowPos ( 0x000000000002043c, HWND_BOTTOM | 0x00000000fffffffe, 0, 0, 0, 0,
    SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE )

A call to SetWindowPos with HWND_BOTTOM | 0x00000000fffffffe (-2 + 1 = -1 = HWND_TOPMOST) is what we are after and the process that does this call is the one you should blame for your problem.

I give up... How can I remedy my "Always On Top" problem?

Battle fire with fire, we're going to set all windows to HWND_NOTOPMOST.

Yikes, programming! But, this can easily be done through scripting too...

So a very simple homework task:

  • Download AutoIt v3.

  • Create a ByeByeTopMost.au3 file that contains:

    While 1
        $var = WinList()
    
        For $i = 1 to $var[0][0]
            WinSetOnTop($var[$i][1], "", 0)
        Next
    
        Sleep(5000)
    WEnd
    
  • Place it in your start-up folder and run it or reboot.

Or if you don't like homework at all, download this zip file I made.

Have fun... :-)

PS: You can't use the "Always On Top" feature in this last case. Either troubleshoot or work-around... ;-)