Previously I said lookup FindNext - I meant FindKey
Locate - Not available ihn Delphi1. But FindKey and FindNearest are.
 
Sorry, Too early in the morning!

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On
Behalf Of Mike Osborne
Sent: Thursday, 10 June 1999 22:29
To: Multiple recipients of list delphi
Subject: Re: [DUG]: What the 'L' is the problem?


More on this:
A similar function but traversing a TOutline in one condition or doing a
FindNearest in another is terminating when 'C' is pressed but is fine
with 'L'.
Is KeyDown an unreliable event in D1? 

-----Original Message-----
From: Mike Osborne < [EMAIL PROTECTED]>
To: Multiple recipients of list delphi < [EMAIL PROTECTED]>
Date: Thursday, 10 June 1999 22:02
Subject: [DUG]: What the 'L' is the problem?


I suspect the following has either a very complex or very stupid
explanation.
Advice please.
 
In a D1 app I display a grid from a query sequenced by Description. When
the user presses a character key I position in the grid to the first
entry with that letter. The Datasource gets detached and attached
because it looks ugly watching the progress and detached is much faster.
 
So far so good.
 
The function works fine for every letter other than the letter 'L'. I
have been through the alphabet on this, all but 'L' is OK. When 'L' is
pressed, the program terminates.
 
This same problem has been reported on a different (client's) machine
also. The problem occurs with different data as well. Same problem if
there is Description beginning with 'L' or not.
 
In debug I can trace it as far as the "while" loop - it seems to spin
out at that point.
 
procedure TViewer.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if (Key = VK_RETURN) then
    OKBtnClick(Sender);
  if (not (chr(Key) < 'A') and (not (chr(Key) > 'Z')))
  or (not (chr(Key) < 'a') and (not (chr(Key) > 'z')))
  or (not (chr(Key) < '0') and (not (chr(Key) > '9'))) then begin
    Screen.Cursor := crHourGlass;
    DBGrid1.DataSource := Nil;
    with qrydash do begin
      if (copy(Fields[2].asstring,1,1) > chr(Key)) then begin
        First;
      end;
      while ((copy(Fields[2].asstring,1,1) < chr(Key)) and (not eof)) do
begin
        Next;
      end;
 
      { if no entries for a letter, show previous highest entry }
      if (copy(Fields[2].asstring,1,1) <> chr(Key)) and not eof then
begin
        Prior;
      end;
    end;
    DBGrid1.DataSource := DS;
    Screen.Cursor := crDefault;
  end;
end;

---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz

Reply via email to