title: How Do I Get the Usable Coordinates of the Screen in Delphi
body: <p>With Screen.DesktopHeight and Screen.DesktopWidth, I can get the size of the "virtual" desktop and I believe that works for one or multiple monitors.</p>
  
  <p>I save the position (top and left) and size (height and width) of my application into the registry when it closes. When it opens, I want to ensure it is entirely visible, since it may have been moved partly outside the visible area, or the screen size may have changed for example via screen settings or removal of a monitor.</p>
  
  <p>I can basically do it with this code:</p>
  
  <pre><code>if MyForm.Width &gt; screen.DesktopWidth then 
    MyForm.Width := screen.DesktopWidth;
  
  if MyForm.Height &gt; screen.DesktopHeight then 
    MyForm.Height := screen.DesktopHeight;
  
  if (MyForm.Left + MyForm.Width) &gt; screen.DesktopWidth then 
    MyForm.Left := screen.DesktopWidth - MyForm.Width;
  if MyForm.Left &lt; 0 then MyForm.Left := 0;
  
  if (MyForm.Top + LogoAppForm.Height) &gt; screen.DesktopHeight then 
    MyForm.Top := screen.DesktopHeight - LogoAppForm.Height;
  if MyForm.Top &lt; 0 then MyFormTop := 0;
  </code></pre>
  
  <p>This works okay, except it does not take into account the taskbar that is usually (but not always) at the bottom of the desktop. So if the taskbar is in the way of my application's window, my application gets obscured.</p>
  
  <p>How can I get the usable position and size settings of the screen that exclude the location of the taskbar?</p>