title: How to implement IsFirstRecord and IsLastRecord?
body: <p>I like to disable controls when it's pointless for the user to click on them.</p>
  
  <p>One special case is a set of custom menu buttons that emulate the first, prior, next and last buttons of a standard <code>TDBNavigator</code>.</p>
  
  <p>When the user clicks on the first button, the first and prior buttons are both disabled.</p>
  
  <p>When the user then clicks the next and prior buttons the underlying <code>TDataSet</code> is positioned on the same record as before, but the first and prior buttons are both still enabled.</p>
  
  <p>The current implementation looks like this:</p>
  
  <pre><code>NavigationFirstButton.Enabled := not DataSet.IsEmpty and not DataSet.Bof;
  NavigationPriorButton.Enabled := not DataSet.IsEmpty and not DataSet.Bof;
  NavigationNextButton.Enabled  := not DataSet.IsEmpty and not DataSet.Eof;
  NavigationLastButton.Enabled  := not DataSet.IsEmpty and not DataSet.Eof;
  </code></pre>
  
  <p><code>Bof</code> and <code>Eof</code> are not the right way to disable the buttons, because I have to know beforehand if the current record is going to be the first/last record.</p>
  
  <p>So I thought of rewriting this using a <code>IsFirstRecord</code> and <code>IsLastRecord</code> method:</p>
  
  <pre><code>function IsFirstRecord(ADataSet: TDataSet): Boolean;
  begin
      Result := ADataSet.RecNo = 0;
  end;
  
  function IsLastRecord(ADataSet: TDataSet): Boolean;
  begin
      Result := ADataSet.RecNo = ADataSet.RecordCount - 1;
  end;
  </code></pre>
  
  <p>I don't think that this is a good idea, since I've seen cases where for the first record <code>RecNo = 0</code> is not true. (i.e. A filtered TADSQuery)</p>
  
  <p>What is a reliable implementation for <code>IsFirstRecord</code> and <code>IsLastRecord</code>? Is it even possible using the current <code>TDataSet</code> architecture?</p>