Re: keybd_event
From: AlanGLLoyd (alanglloyd_at_aol.com)
Date: 09/08/04
- Next message: operator: "ActiveX Installer"
- Previous message: Boefje: "Quickreport : Seperate multiple page report from single page reports"
- In reply to: Stark: "keybd_event"
- Next in thread: Stark: "Re: keybd_event"
- Reply: Stark: "Re: keybd_event"
- Reply: Stark: "Re: keybd_event"
- Reply: Stark: "Re: keybd_event"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 08 Sep 2004 10:30:42 GMT
In article <NFFZc.187878$OR2.8749904@news3.tin.it>, "Stark"
<franco.jommi@tin.it> writes:
>I've learned how to simulate sending characters to the keyboard, but I only
>know how to send numbers. I want to trap any character the user types in an
>edit window and send them to a ComboBox so that it opens and it highligths
>any line matching the typed digits.
>
>I was trying the following :
>
>Edit1KeyPress(Sender: TObject; var Key: Char);
>var
> Car: char;
>begin
> ComboBox1.SetFocus;
> keybd_event(ord(Key), 0, 0, 0); //this only works with numbers
> Edit1.SetFocus;
> .....
>end;
>
>How can I replace ord(Key) so that I can send any alphanumeric character ?
>
Don't forget ...
1 keybd_event should have a key up as well as a key down.
2 Its parameter is a KEY, not a character. Keys on a keyboard are a key and are
interpreted to a character.
The following works for me in D3. If you have a later Delphi, the virtual
key-codes VK_0 to VK_Z may be defined. Note that unlike characters, the value
for VK_SPACE is not part of the continuum with '0' to 'Z'.
procedure TForm1.Edit1KeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
var
Idx : integer;
const
VK_0 : word = Ord('0'); // VK_<zero> not defined in D3
VK_Z : word = Ord('Z'); // not defined in D3
begin
if (Key in [VK_SPACE,VK_0..VK_Z]) then begin
Idx := ComboBox1.Perform(CB_FINDSTRING, 0, integer(PChar(Edit1.Text)));
if (Idx = CB_ERR) then
ComboBox1.DroppedDown := false
else begin
ComboBox1.DroppedDown := true;
ComboBox1.ItemIndex := Idx;
ComboBox1.Refresh;
end; {if (Idx = CB_ERR) else}
end;
end;
Alan Lloyd
alanglloyd@aol.com
- Next message: operator: "ActiveX Installer"
- Previous message: Boefje: "Quickreport : Seperate multiple page report from single page reports"
- In reply to: Stark: "keybd_event"
- Next in thread: Stark: "Re: keybd_event"
- Reply: Stark: "Re: keybd_event"
- Reply: Stark: "Re: keybd_event"
- Reply: Stark: "Re: keybd_event"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|