Discussion:
Inactive top window?
(too old to reply)
David Olsson
2005-01-03 12:01:15 UTC
Permalink
Hello!

I'm trying to place a window on top of all other windows without making
it active. I have made attempt with the SetWindowPos API call:

SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE |
SWP_NOMOVE | SWP_NOSIZE);

This, however, appears to have no effect. If I remove the SWP_NOACTIVATE
flag, the window is moved to the top. It does however (obviously) get
activated which is something I, in this case, do not want. Am I missing
something? Or there is another API call which provides the functionality
I am looking for?
George Ionescu
2005-01-04 07:36:59 UTC
Permalink
Hello David,
Post by David Olsson
I'm trying to place a window on top of all other windows without making
SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE |
SWP_NOMOVE | SWP_NOSIZE);
you forgot the SWP_SHOWWINDOW flag:

SetWindowPos (hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE |
SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
--
Best Regards,
George Ionescu

SQLiteDb - fast, powerful and lightweight database engine
http://www.terrainformatica.com/sqlitedb

Terra Informatica Software inc.
http://www.terrainformatica.com
David Olsson
2005-01-04 09:07:35 UTC
Permalink
Post by George Ionescu
Hello David,
Post by David Olsson
I'm trying to place a window on top of all other windows without
SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE |
SWP_NOMOVE | SWP_NOSIZE);
SetWindowPos (hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE |
SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
Thanks for the reply. I should have written that I tried with that flag
as well, without success. As far as I can gather, this is the API call
used to implement "always on top" behaviour. And since windows that are
"always on top" aren't always active, I'm guessing there is a way to do
this :-).

Thanks for any other suggestions
David Olsson
Sten Westerback
2005-01-14 14:28:58 UTC
Permalink
Post by David Olsson
Post by George Ionescu
Hello David,
Post by David Olsson
I'm trying to place a window on top of all other windows without
SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE |
SWP_NOMOVE | SWP_NOSIZE);
SetWindowPos (hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE |
SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
Thanks for the reply. I should have written that I tried with that flag
as well, without success. As far as I can gather, this is the API call
used to implement "always on top" behaviour. And since windows that are
"always on top" aren't always active, I'm guessing there is a way to do
this :-).
If the topmost really implies show then there is as i see it two solutions:
1. SW_HIDE , topmost, SW_SHOWNOACTIVATE
2. hwnd=GetForgroundWindow(), topmost, SetForgroundWindow(hwnd)

- Sten

AliR
2005-01-04 21:30:51 UTC
Permalink
It all kinda depends on where you are doing this. Anyway if the window that
you are trying to change the Zorder of is not already active call
SetWindowPos with the SWP_NOACTIVATE flag.

AliR.
Post by David Olsson
Hello!
I'm trying to place a window on top of all other windows without making
SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE |
SWP_NOMOVE | SWP_NOSIZE);
This, however, appears to have no effect. If I remove the SWP_NOACTIVATE
flag, the window is moved to the top. It does however (obviously) get
activated which is something I, in this case, do not want. Am I missing
something? Or there is another API call which provides the functionality
I am looking for?
Ken Wickes [MSFT]
2005-01-10 23:36:20 UTC
Permalink
I would guess that the window you are trying to make topmost is not active
when you are trying to make it topmost. I ran into this problem when
writing an app bar at tries to respond correctly to full screen app
notifications. I spent a lot of time debugging this and concluded it is a
defect in Windows, but they haven't gotten back to me yet.

IIRC, I worked around this in the end by not having any owned windows at the
time I need to make the window topmost. For me this meant making my
tooltips topmost and not owned by the parent window. Not a great solution,
but works reasonably well.
--
Ken Wickes [MSFT]
This posting is provided "AS IS" with no warranties, and confers no rights.
Post by AliR
It all kinda depends on where you are doing this. Anyway if the window that
you are trying to change the Zorder of is not already active call
SetWindowPos with the SWP_NOACTIVATE flag.
AliR.
Post by David Olsson
Hello!
I'm trying to place a window on top of all other windows without making
SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE |
SWP_NOMOVE | SWP_NOSIZE);
This, however, appears to have no effect. If I remove the SWP_NOACTIVATE
flag, the window is moved to the top. It does however (obviously) get
activated which is something I, in this case, do not want. Am I missing
something? Or there is another API call which provides the functionality
I am looking for?
Loading...