Board index » delphi » 2 Delphi questions

2 Delphi questions

I have two Delphi questions:

1. Where are all the virtual-key codes defined (which unit)?

2. Is there a way to capture and broadcast entered characters to
multiple components (i.e. character entered shows up simultanously in
two Edit Boxes) ?

Thanks
Jenny

 

Re:2 Delphi questions


Jenny,
  The Virtual key codes are defined in the Windows.pas unit.  For your
second question try the following:

procedure TForm1.Edit1Change(Sender: TObject);
begin
  Edit2.Text := Edit1.Text;
end;

Hope this helps!
--
Rod Geraghty (:>)
GERA-Tech
Ottawa, Canada
gera...@ibm.net

Jenny Lu <je...@lotuspacific.com> wrote in article
<33133F9F.4...@lotuspacific.com>...

Quote
> I have two Delphi questions:

> 1. Where are all the virtual-key codes defined (which unit)?

> 2. Is there a way to capture and broadcast entered characters to
> multiple components (i.e. character entered shows up simultanously in
> two Edit Boxes) ?

> Thanks
> Jenny

Re:2 Delphi questions


Quote
Jenny Lu <je...@lotuspacific.com> wrote:
>I have two Delphi questions:
>1. Where are all the virtual-key codes defined (which unit)?

D1: WinTypes -- D2: Windows

Quote
>2. Is there a way to capture and broadcast entered characters to
>multiple components (i.e. character entered shows up simultanously in
>two Edit Boxes) ?

I would do this by setting the form's KeyPreview property to true, and
the in the OnKeyDown check the form's active control, and then use
SendMessage to send an appropriate keydown message to the appropriate
controls.

Alternatively, create a keyboard hook, from which you could (possibly)
use SendMessage easier.

Regards,

Jani J?rvinen
a.k.a SilverStream Software
Helsinki Finland

Tools, information, tips, reviews & bug lists
for professional Delphi, Win32 and WinHelp developers.

mailto:ja...@dystopia.fi
http://www.dystopia.fi/~janij/

Re:2 Delphi questions


Quote
Jenny Lu wrote:

> I have two Delphi questions:

> 1. Where are all the virtual-key codes defined (which unit)?

> 2. Is there a way to capture and broadcast entered characters to
> multiple components (i.e. character entered shows up simultanously in
> two Edit Boxes) ?

> Thanks
> Jenny

Jenny
Re your 1.
Scan codes are *not* defined in the help; an easy way to get the values
is to write a one-form app; on keydown, showmessage(inttostr(scancode))
sort of thing; this is what I resorted to.....
Re your 2. This is easier.
For EditBox1, define the OnChange event as e.g.
procedure EditBox1OnChange(blah blah);
begin
        EditBox2.Text := EditBox1.Text;
        .....
        EditBoxn.Text := EditBox1.Text;
end;
HTH
Peter Hill
end;

Other Threads