title: Avoid that SetFocus raises an Exception
body: <p>I am working at a huge, legacy source code where several <code>SetFocus</code> is called at many places, but sometimes, the check if the control is visible or enabled is missing.</p>
  <p>Due to limited time, and the huge amount of source code, I decided that I want to ignore these errors, since the focus is (in our case) not a critical feature. A raised Exception will result in a complete failure, while a missing focus is just an optical issue.</p>
  <p>My current plan is following:</p>
  <ol>
  <li><p>I create an unit with a class helper like this:</p>
  <p>type
  TWinControlEx = class helper for TWinControl
  procedure SetFocusSafe;
  end;</p>
  <p>procedure TWinControlEx.SetFocusSafe;
  begin
  if CanFocus then SetFocus;
  end;</p>
  </li>
  <li><p>I include the unit to every unit which uses &quot;.SetFocus&quot; (I will use the global code search)</p>
  </li>
  <li><p>I replace every .SetFocus with .SetFocusSafe</p>
  </li>
  </ol>
  <p>There is a problem though: If possible, I want to avoid that coworkers accidently use .SetFocus , or forget to include the classhelper unit.</p>
  <p>Which other options do I have?</p>
  <p>The best case would be if there is a technique/hack to make SetFocus not raising an exception. (Without recompiling the VCL)</p>