Please see my comment to the question. Maybe the MSDN documentation is not quite clear about the subject but the specific purpose of the property
TopMost
is to show the form of top of all other forms on the desktop regardless of their activation:
http://msdn.microsoft.com/en-us/library/system.windows.forms.form.topmost%28v=vs.110%29.aspx[
^].
This effect is used quite rarely, because it can distract from other applications, so it is used only in some very important critical need of some very special applications. If you want something else, you should not use
TopMost
. But then, if setting this property to false won't solve the problem you are trying to solve, you should explain the behavior your want. And you always need to explain why you want something.
[EDIT]
How to get a handle?
If you have a form instance, that's
Form.Handle
:
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.handle.aspx[
^].
In all other cases, you can get an instance of some process (your current
System.Diagnostics.Process.GetCurrentProcess
or any other one) and get the handle of a main window of the corresponding application using
System.Diagnostics.Process.MainWindowHandle
:
http://msdn.microsoft.com/en-us/library/vstudio/system.diagnostics.process.mainwindowhandle[
^].
Pay attention for the exception which can be thrown is there is not handle. Therefore, you generally have to call this property under a try-catch block.
—SA