TIP: Click on subject to list as thread! ANSI
echo: delphi
to: HANS TAP
from: CARLOS SANCHEZ GARCIA
date: 1997-10-07 21:45:00
subject: Change keyboard layout

Hi Hans!
Mr. Hans Tap wrote to Mr. Carlos Sanchez Garcia:
 HT> event for all my Edit controls. However, I want a GENERAL solution for
 HT> the whole application. There must be a way to generate a common
 HT> keyboard change for this??.
    Umm..., anyway what I told you doesn't seem to work fine. Here I have a 
solution extracted from SWAG Snippets:
#### INICIO  ####
Code to make the key act as the tab key while inside a grid.
This code also includes the processing of the  key for the entire
application - including fields, etc.  The grid part is handled in the
ELSE portion of the code.  The provided code does not mimic the behavior
of the  key stepping down to the next record when it reaches the last
column in the grid - it moves back to the first column - .
procedure TForm1.FormKeyPress(Sender: TObject; var Key: Char);
{ This is the event handler for the FORM's OnKeyPress event! }
{ You should also set the Form's KeyPreview property to True }
begin
  if Key = #13 then                              { if it's an enter key }
    if not (ActiveControl is TDBGrid) then begin { if not on a TDBGrid }
      Key := #0;                                 { eat enter key }
      Perform(WM_NEXTDLGCTL, 0, 0);              { move to next control }
    end
    else if (ActiveControl is TDBGrid) then      { if it is a TDBGrid }
      with TDBGrid(ActiveControl) do
        if selectedindex < (fieldcount -1) then  { increment the field }
          selectedindex := selectedindex +1
        else
          selectedindex := 0;
end;
#### FIN: Xx.Txt ####
    Anyway remember that you can make a lot of controls call te same event by 
selecting all of them and then double-click in the desired event on the 
events tab on the object Inspector. The event procedure will be called as one 
of the controls, but all of them will call it ;)
 See you :)
--- FMail 1.02
---------------
* Origin: Edison's Temple BBS - Madrid (2:341/136.39)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.