Here my solution to making complex table links lightning fast in
Delphi/Apollo when scrolling tables. I'd be interested in feedback.
Two windows show two tables. They are linked by a common field.
However, it is not possible to use the Delphi lookup function. That
would be nice and fast. But for Apollo ttSXNTX this is not supported.
One might use Apollo SetRelation(). However, whatever seek method one
uses, this works like a slug. On a 486, looking up the correct record
in the other table takes 1/10th second. That is SLOW. The user wants
to scroll through the table FAST, not waste time waiting for the
The issue is to update Table2 only when the record pointer in Table1
has moved or when the table is first opened. At all other times,
repositioning the cursor serves only to slow the scrolling display to
a grind. One can test whether the pointer has moved in the TDataSource
OnDataChange() event handler. This "fires" whenever the record pointer
moves. It fires repeatedly on scrolling, however, slowing things down.
The question therefore is how to let the user scoll the table FAST.
I did a simple customised TDBGrid. I popped in OnClick(),
OnMouseDown() and OnMouseUp(). So I thought wonderful: I will update
the other table whenever the user STOPS scolling. This is whenever the
user does a OnMouseUp() or OnKeyUp() for the cursor keys 33-40.
If the record pointer is moved by a single mouse repositioning and
click, then the OnDataChange() will cover this and reposition the
Using OnClick() by itself, without OnDataChange(), would have been
nice, but it does not work. The reason is that the OnClick() seems to
"fire" all the time when scrolling from record to record, even though
the mouse is not even used.
Sadly, I also find this:
- OnMouseUp() works only inside the grid, not when the user presses
the scroll bars of the grid.
- Scrolling is therefore still very slow if the user presses the
"proper Windows buttons" on the scroll bar.
- Trapping OnMouseUp() with TForm's Key Preview:=true simply does
not seem work!! Could the reason be that the form does not
have active control? It makes no sense, but doesn't work anyway.
However, on cursor keys the scrolling is now very fast. I found I had
to put a public variable flag into the OnDataChange() which turns the
"seek" function "off" while scrolling and "on" when the MouseUp or
I'd be interested in feedback.