Author Topic: Program loses HWND_TOPMOST status  (Read 781 times)

jj2007

  • Member
  • *****
  • Posts: 13957
  • Assembly is fun ;-)
    • MasmBasic
Program loses HWND_TOPMOST status
« 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?

Biterider

  • Member
  • *****
  • Posts: 1083
  • ObjAsm Developer
    • ObjAsm
Re: Program loses HWND_TOPMOST status
« Reply #1 on: September 08, 2022, 08:43:06 PM »
Hi JJ
No, I've never experienced anything like this.

Biterider

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 10583
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Program loses HWND_TOPMOST status
« Reply #2 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.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

jj2007

  • Member
  • *****
  • Posts: 13957
  • Assembly is fun ;-)
    • MasmBasic
Re: Program loses HWND_TOPMOST status
« Reply #3 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.

tenkey

  • Member
  • **
  • Posts: 51
Re: Program loses HWND_TOPMOST status
« Reply #4 on: September 09, 2022, 10:32:32 AM »
I've always wondered what happens when two windows get topmost status.

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 10583
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Program loses HWND_TOPMOST status
« Reply #5 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.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

NoCforMe

  • Member
  • *****
  • Posts: 1124
Re: Program loses HWND_TOPMOST status
« Reply #6 on: September 09, 2022, 02:48:17 PM »
- 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:

jj2007

  • Member
  • *****
  • Posts: 13957
  • Assembly is fun ;-)
    • MasmBasic
Re: Program loses HWND_TOPMOST status
« Reply #7 on: September 09, 2022, 06:21:39 PM »
If 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:

NoCforMe

  • Member
  • *****
  • Posts: 1124
Re: Program loses HWND_TOPMOST status
« Reply #8 on: September 09, 2022, 09:03:11 PM »
So maybe it's something else other than where it's launched from ...

mikeburr

  • Member
  • **
  • Posts: 189
Re: Program loses HWND_TOPMOST status
« Reply #9 on: September 10, 2022, 09:01:44 AM »
jj .. overwriting something ?? eg subscript error etc ??
regards mike b

jj2007

  • Member
  • *****
  • Posts: 13957
  • Assembly is fun ;-)
    • MasmBasic
Re: Program loses HWND_TOPMOST status
« Reply #10 on: September 10, 2022, 09:04:19 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*.

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 10583
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Program loses HWND_TOPMOST status
« Reply #11 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.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy: