Title: Message
Yes I can pass on an excellent trick someone here gave me, and is useful in any component you choose it to apply to - just put this code or a tweaked version in the form unit:
 
Make sure you declare the procedure in the form with the extra syntax:
 
     procedure CMDialogKey(Var Msg: TWMKEY); message CM_DIALOGKEY;
 
Apart from that it doesn't need any more coding - it intercepts the messages behind the scenes and alters the key.  Works a charm
 
my version
----------
procedure TfrmCoinqSrch.CMDialogKey(var Msg: TWMKEY);
{
   This converts ENTER key messages to TAB key messages, provided a few
   conditions hold - this adds ability also to abort/exit with escape key - Keydir is a global variable I test in various events
}
begin
   if   (ActiveControl is TCustomEdit)
//     or (ActiveControl is TDBCode)
//     or (ActiveControl is TPageControl)
//     or (ActiveControl is TDBLookupComboBox)
     or (ActiveControl is TRadioButton)
     or (ActiveControl is TStringGrid)
   then
     begin
       if Msg.CharCode = VK_RETURN then
       begin
         Msg.CharCode := VK_TAB;
         KeyDir:='Next';
       end;
       if Msg.Charcode = VK_ESCAPE then
       begin
         Msg.CharCode := VK_TAB;
         KeyDir:='Prev';
       end;
     end;
   inherited;
end;
 
original
To Convert Enter to Tab I use the following code:
 
Attached to the form:
     procedure CMDialogKey(Var Msg: TWMKEY); message CM_DIALOGKEY;
 

procedure TMyForm.CMDialogKey(var Msg: TWMKEY);
{
   This converts ENTER key messages to TAB key messages, provided a few
   conditions hold
}
begin
   if   (ActiveControl is TCustomEdit)
     or (ActiveControl is TDBCode)
     or (ActiveControl is TPageControl)
     or (ActiveControl is TDBLookupComboBox)
     or (ActiveControl is TDBComboBox)
   then
     if Msg.CharCode = VK_RETURN then
       Msg.CharCode := VK_TAB;
   inherited;
end;
 
 

John Bird

email [EMAIL PROTECTED]

Consultant for Beyond Data Systems/Acclipse Legal

Ph land (03)384-4527  mobile (027)484-4528

92 Soleares Ave, Mt Pleasant

Christchurch

Web www.123.co.nz/johnbird

 

 

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Robert Wilson
Sent: Friday, 22 April 2005 3:43 p.m.
To: [email protected]
Subject: [DUG] Re: DBGrid



Hi

Friday afternoon and Help!!
Trying to get enter key to behave like tab in a dbgrid. I'm sure it is something really simple that I i'm missing!
Help would be appreciated.

Cheers
Robert

Cellular Cellnet Ltd NZ.
Attention:
Disclaimer:

The information in this electronic mail message is confidential and may be legally privileged. It is intended solely for the addressee. Access to this Internet electronic mail message by anyone else is unauthorised.

If you are not the intended recipient, any disclosure, copying, distribution or any action taken or omitted to be taken in reliance on it is prohibited and may be unlawful.
If you  have received this e-mail by mistake please call the sender immediately on 09 415 4747 and erase the original message and any attachments.

Cellular Cellnet (NZ) Ltd accepts no responsibility for any effects this email message or attachments has on the recipient network or computer system.


_______________________________________________
Delphi mailing list
[email protected]
http://ns3.123.co.nz/mailman/listinfo/delphi

Reply via email to