Nasty gotcha: Positioning your window beneath a topmost window makes it topmost
There’s a nasty gotcha with the
DeferWindowPos function, and therefore any functions built on top of it, such as
SetWindowPos: If you specify a
hwndInsertAfter, and the insert-after window is topmost, then the window being positioned will be placed immediately after that window.
So far so good.
The hidden gotcha is that the window will be placed in the same zone as the insert-after window, which is the topmost zone.
In other words, the window will be made topmost, even if it wasn’t topmost previously.
Which is probably not what you were expecting.