System Delphi

Title: Preventing tab from switching controls
Question: I want to use the tab key for auto-complete, not to switch controls. How can I do this?
Answer:
Info:
First stage is to prevent the tab key from performing its usual function. It can be trapped like this:
Definition:
procedure CMDialogKey( Var msg: TCMDialogKey ); message CM_DIALOGKEY;
Declaration:
procedure TMainFrm.CMDialogKey(var msg: TCMDialogKey);
begin
if msg.Charcode VK_TAB then
inherited;
end;
Now the KeyDown procedure for your control 'sees' the tab being pressed, so its just a matter of:
procedure TmainFrm.TextBoxKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
if Key = VK_TAB then
(autocomplete code)
end;
Easy when you know how.
Tested with D5 and w2k/95/98 and NT4. Should work fine with other delphi versions, but untested.