Donald:
Trap the Enter key at the form level using the code at the end of the message.
If you want it active just for edit controls, add:
if ActiveControl is TEdit then
before the line
if AMessage.CharCode = VK_RETURN then begin
--
Regards
Ralph (TeamB)
(No private e-mail replies, please, unless explicitly requested).
--
Quote
Donald Borneman wrote in message <751p2e$l...@forums.borland.com>...
|I am using the OnKeyPress event of a TEdit component to analyze and filter
|user input. I want the user to be able to provide the proper input and
|use the ENTER key to move to the next field. The tab key is OK, but I
|feel the ENTER key should also be capable of this function. The problem
|is that for some reason, Delphi won't recognize the ENTER key as a
|lagitimate key stroke. I don't know why that is. Here is a sample of
|what is happening.<deletia>
unit EnterTabCM;
interface
uses
Windows, Messages, Classes, Forms, StdCtrls, Controls;
type
TFrmEnterTabCM = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Label1: TLabel;
private { Private-Deklarationen }
procedure CMDialogKey(var AMessage: TCMDialogKey); Message CM_DIALOGKEY;
public { Public-Deklarationen }
end;
var
FrmEnterTabCM: TFrmEnterTabCM;
implementation
{$R *.DFM}
procedure TFrmEnterTabCM.CMDialogKey(var AMessage: TCMDialogKey);
begin
if AMessage.CharCode = VK_RETURN then begin
if GetKeyState(VK_SHIFT) < 0 then
SelectNext(ActiveControl, false, true)
else
SelectNext(ActiveControl, true, true);
AMessage.Result := 1;
end;
inherited;
end;
end.