What I'm trying to do is simple: make my WinForm on top of another, but not topmost. Like, when I click on a window, my winform will be on top of it, but when I click on something else, like a browser, my form will not be on top of it.
Like a TopMost WinForm, but only for a specific process. (Im making a overlay for a game, so I need it to be topmost ONLY on the game.)
Pictures to help (Everything inside the RED border is my form):
And then when I change to another window (In this case, Explorer) I want my form to be in the background, just like the League of Legends client
Owned forms are always displayed on top of their owner form. To make a form owned by an owner, you can assign a reference of the owner form to
Onwer
property of the owned form, for example:Set a Window of another Process as Owner
To do so, you should first find the handle of window of the other process, then using
SetWindowLong
API function, you can set it as owner of your form, for example:In above example, your form will be always on top of the notepad window.