Click here to Skip to main content
15,881,139 members
Please Sign up or sign in to vote.
5.00/5 (2 votes)
See more:
Hi all.

I create a window using the following:

SetWindowPos( hWnd ,HWND_TOPMOST, x, y, xx, yy, SWP_SHOWWINDOW | SWP_FRAMECHANGED );


Now if any other topmost window (for example Windows Task Manager) is launched the click on that window will bring it to the front. Then clicking on my window will bring the last to the front.

Is it possible to create a window that will always be over other windows which are created later? :)

[Edited after first 2 answers]
Well... I'll ask a question in other way, cause I've not asked a question "can I create most topmost of the top of the most topmost ...... (n+1)*(of the most topmost) window?" :)

Imagine that my application has 2 windows: W1 and W2, and they both are topmost.
All I want is W1 to be always in front of W2.

Of course it is possible having for example some if statements, but I wanna know if it is possible to tell the system to control these windows positions.
[End]

Eugen Podsypalnikov wrote:
Would it be not a case
of a modaless dialog (W1),
created by a window (W2) ?


No, this is not what I ask. "W1" and "W2" are independent from each other, so there should be possibility to operate in W1 while W2 is opened and vise versa/>


thanks in advance
Posted
Updated 31-Mar-10 22:55pm
v4

No: this is in fact an abuse of user patience.
If everything want to be topmost nothing will be topmost.

An even introducing another category - and another - and another ... -will just shift the same problem after some time if all devclopers want to be the "most topmost of the top of the most topmost"!

Moral of the story: let the user to decide which window is "topmost" and what is not, depending on what he's doing.
 
Share this answer
 
It would appear not. I have just tested as you described and it would appear that more than one TOPMOST window goes into a new group with their own Z-order. Since they are all competing to be topmost it is up to the user to click on the one that is wanted at any time. If windows had another value e.g. ABSOLUTE_TOPMOST you could still create multiple windows with the property.

The answer to your suplementary question is still "No". Read the MSDN documentation; any number of windows can be TOPMOST windows, but the user still has the choice of which one of them should be at the top of that group. Remember you are writing an application that is to be controlled by the user (otherwise why use Windows?) and that user needs to be able to decide which Window should remain at the top of the group.
 
Share this answer
 
v2
bartello wrote:
Imagine that my application has 2 windows: W1 and W2, and they both are topmost.
All I want is W1 to be always in front of W2.


Would it be not a case
of a modaless dialog (W1),
created by a window (W2) ? :)


bartello wrote:
so there should be possibility to operate in W1 while W2 is opened and vise versa


It would be possible
to operate in W1(a window)
while W2(its modaless dialog) is opened
and vise versa :)
 
Share this answer
 
v3
bartello wrote:
Imagine that my application has 2 windows: W1 and W2, and they both are topmost.
All I want is W1 to be always in front of W2.


If W2 is topmost, set W1 styles WS_POPUP|WS_CHILD and W2 as parent of W1.
It should achieve what you want.
cheers,
AR
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900