Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This isn't directly supported by the .NET Form class, so you have two options:</p> <p>1) Use the Win32 API <a href="http://msdn.microsoft.com/en-us/library/ms633545(VS.85).aspx" rel="nofollow noreferrer"><code>SetWindowPos</code></a> function.</p> <p><a href="http://www.pinvoke.net/default.aspx/user32.SetWindowPos" rel="nofollow noreferrer">pinvoke.net</a> shows how to declare this for use in C#:</p> <pre><code>[DllImport("user32.dll")] static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags); static readonly IntPtr HWND_BOTTOM = new IntPtr(1); const UInt32 SWP_NOSIZE = 0x0001; const UInt32 SWP_NOMOVE = 0x0002; const UInt32 SWP_NOACTIVATE = 0x0010; </code></pre> <p>So in your code, call:</p> <pre><code>SetWindowPos(Handle, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); </code></pre> <p>As you commented, this moves the form to the bottom of the z-order but doesn't keep it there. The only workaround I can see for this is to call <code>SetWindowPos</code> from the <code>Form_Load</code> and <code>Form_Activate</code> events. If your application is maximized and the user is unable to move or minimise the form then you might get away with this approach, but it's still something of a hack. Also the user might see a slight "flicker" if the form gets brought to the front of the z-order before the <code>SetWindowPos</code> call gets made.</p> <hr> <p>2) <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.control.wndproc.aspx" rel="nofollow noreferrer">subclass the form</a>, override the <code>WndProc</code> function and intercept the <a href="http://msdn.microsoft.com/en-us/library/ms632653(VS.85).aspx" rel="nofollow noreferrer">WM_WINDOWPOSCHANGING</a> Windows message, setting the SWP_NOZORDER flag (taken from <a href="https://stackoverflow.com/questions/595888/how-to-prevent-a-control-from-changing-z-order/1133181#1133181">this page</a>).</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload