The MASM Forum

General => The Workshop => Windows API => Topic started by: jj2007 on September 08, 2022, 08:17:18 PM

Title: Program loses HWND_TOPMOST status
Post by: jj2007 on September 08, 2022, 08:17:18 PM
I have a program with HWND_TOPMOST status. After several hours, it suddenly loses that status. Has that ever happened to you?
Title: Re: Program loses HWND_TOPMOST status
Post by: Biterider on September 08, 2022, 08:43:06 PM
Hi JJ
No, I've never experienced anything like this.

Biterider
Title: Re: Program loses HWND_TOPMOST status
Post by: hutch-- on September 08, 2022, 09:20:06 PM
JJ,

Just a rough guess but see if SetWindowPos() is being overwritten or changed by some form of code restart. I never run that setting for very long so I have never seen the problem. Another option is to restart the app to ensure the setting remains.
Title: Re: Program loses HWND_TOPMOST status
Post by: jj2007 on September 09, 2022, 02:59:13 AM
Mystery solved:

- NO, the program doesn't lose the topmost status.
- When I build it, it has the topmost status and keeps it forever.
- However, when I launch it via the Win7 taskbar, it does not get the topmost status, despite the SetWindowPos*.

Does it make sense? NO.
Is it a feature? Certainly, according to Micros*t.
Title: Re: Program loses HWND_TOPMOST status
Post by: tenkey on September 09, 2022, 10:32:32 AM
I've always wondered what happens when two windows get topmost status.
Title: Re: Program loses HWND_TOPMOST status
Post by: hutch-- on September 09, 2022, 10:54:27 AM
JJ,

If the window has been mimimised, when it is restored by clicking on the task bar, set the option in SetWindowPos again.

tenkey,

From memory, the last topmost window has precedence over earlier topmost ones.
Title: Re: Program loses HWND_TOPMOST status
Post by: NoCforMe on September 09, 2022, 02:48:17 PM
Quote from: jj2007 on September 09, 2022, 02:59:13 AM
- However, when I launch it via the Win7 taskbar, it does not get the topmost status, despite the SetWindowPos*.

The taskbar is for losers.  :undecided:
Title: Re: Program loses HWND_TOPMOST status
Post by: jj2007 on September 09, 2022, 06:21:39 PM
Quote from: hutch-- on September 09, 2022, 10:54:27 AMIf the window has been mimimised, when it is restored by clicking on the task bar, set the option in SetWindowPos again.

SetWindowPos has no effect if it was launched from the taskbar (but it works fine when launched from Explorer).

Now that is weird, right? Even weirder: I do have programs that work fine with topmost status launched from the taskbar :badgrin:
Title: Re: Program loses HWND_TOPMOST status
Post by: NoCforMe on September 09, 2022, 09:03:11 PM
So maybe it's something else other than where it's launched from ...
Title: Re: Program loses HWND_TOPMOST status
Post by: mikeburr on September 10, 2022, 09:01:44 AM
jj .. overwriting something ?? eg subscript error etc ??
regards mike b
Title: Re: Program loses HWND_TOPMOST status
Post by: jj2007 on September 10, 2022, 09:04:19 AM
Quote from: jj2007 on September 09, 2022, 02:59:13 AM
- When I build it, it has the topmost status and keeps it forever.
- However, when I launch it via the Win7 taskbar, it does not get the topmost status, despite the SetWindowPos*.
Title: Re: Program loses HWND_TOPMOST status
Post by: hutch-- on September 10, 2022, 10:43:23 AM
I just tested the small memstat app which is set to always on top and you can minimise it to the task bar then restore it and it keeps its always on top status after being minimised and restored multiple times. This is on current Win10 64.