title: How to get ClientHeight of Screen on C++ Builder
body: <h2>Issue</h2>
  
  <p>The evil Windows taskbar is hiding part of one designed tool window (I don't wanna it to be Always on Top).</p>
  
  <p>How to get ClientHeight of Screen easily????</p>
  
  <h2>Detailed description</h2>
  
  <p>I designed a template dialog, <code>RadioGroupDialog</code>, with a tool window with only a <code>TRadioGroup</code> on it, with <code>Form-&gt;AutoSize = true</code>. It is called through its <code>Execute()</code> method.</p>
  
  <p>On <code>Execute()</code>, one has to pass a <code>TStringList</code> with items to put on the <code>TRadioGroup</code>, the caption of dialog form and the <code>TRect</code> with Screen absolute coordinates of component where the dialog form will be centered in (i.e., <code>Place-&gt;Left = CallingForm-&gt;Left + Component-&gt;Left</code>etc.)</p>
  
  <p>Inside the code of <code>Execute()</code>, after performing some type of autosize to allocate all elements of the <code>TStringList</code> in <code>TRadioGroup</code> and after centering the dialog form in expected position, the code tries to maintain dialog position inside Screen.</p>
  
  <p>It is all ok with up, left and right borders, but, because of Windows taskbar, the dialog is covered by it :(</p>
  
  <p>If I can discover ClientHeight of screen, it will be easy to avoid that issue using it instead of <code>Screen-&gt;Height</code>... Also knowing taskbar height would help. Well, I know that that taskbar would be on top, on left and on right of Screen too, so using ClientHeight and ClientWidth would be the best solution..</p>
  
  <h2>The code of Execute()</h2>
  
  <pre><code>//---------------------------------------------------------------------------
  int __fastcall TRadioGroupDialog::Execute(TStringList *Str, AnsiString DlgCaption, TRect Place)
  {
      ModalResult = 0;
  
      Caption = DlgCaption;
  
      RadioGroup1-&gt;Items-&gt;Clear();
      RadioGroup1-&gt;Items-&gt;AddStrings(Str);
  
      int TheHeight = 30*RadioGroup1-&gt;Items-&gt;Count;
      int MaxHeight = 4*Screen-&gt;Height/5;
      int MinHeight = 30;
  
      if(TheHeight &gt; MaxHeight)
      {
          TheHeight = MaxHeight;
      }
      else if(TheHeight &lt; MinHeight)
      {
          TheHeight = MinHeight;
      }
  
      RadioGroup1-&gt;Height = TheHeight;
  
      Left = ((Place.Left + Place.Right)/2) - Width / 2;
      Top = ((Place.Top + Place.Bottom)/2) - Height / 2;
  
      if(Left + Width &gt; Screen-&gt;Width)
      {
          Left = Screen-&gt;Width - Width;
      }
  
      if(Top + Height &gt; Screen-&gt;Height)
      {
          Top = Screen-&gt;Height - Height;
      }
  
      if(Left &lt; 0)
      {
          Left = 0;
      }
  
      if(Top &lt; 0)
      {
          Top = 0;
      }
  
      RadioGroup1-&gt;ItemIndex = -1;
  
      return ShowModal();
  }
  //---------------------------------------------------------------------------
  </code></pre>
  
  <h2>The ugly thing that Windows taskbar does</h2>
  
  <p>Example: Form1 contains Button1, and when it is pressed it shows the <code>RadioGroupDialog</code> with four items centered in Button1 with "Olá" of dialog caption:</p>
  
  <ul>
  <li><p>Form on screen center:
  <img src="https://i.stack.imgur.com/PdeeR.png" alt="1"></p></li>
  <li><p>Form on screen center after Button1 is pressed:
  <img src="https://i.stack.imgur.com/UwYy7.png" alt="2"></p></li>
  <li><p>Form on bottom of screen:
  <img src="https://i.stack.imgur.com/ptPZd.png" alt="3"></p></li>
  <li><p>Form on bottom of screen after Button1 is pressed (see that 4th item is not shown):
  <img src="https://i.stack.imgur.com/kZQrV.png" alt="4"></p></li>
  </ul>