Re: keybd_event

From: Stark (franco.jommi_at_tin.it)
Date: 09/09/04


Date: Thu, 09 Sep 2004 13:53:01 GMT

I did not know the ComboBox1.Perform instruction; is that something like
IndexOf ?

"AlanGLLoyd" <alanglloyd@aol.com> ha scritto nel messaggio
news:20040908063042.10083.00000474@mb-m11.aol.com...
> 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



Relevant Pages

  • PC-like keyboard for console
    ... ALT-<keyboard character> does not produce the character ... My ALT key is working, ... I installed the emacs keyboard and now the NUM ... # code base shift cntrl shift alt shift cntrl shift state ...
    (comp.unix.bsd.freebsd.misc)
  • Re: In Word, how can I place a bar above a letter to show a mean?
    ... most certainly is far more convenient to assign a keyboard shortcut to ... have any idea how to find instructions in creating a macro. ... keyboard short cut for every possilble keyboard character, ... Word MVP web sitehttp://word.mvps.org ...
    (microsoft.public.word.docmanagement)
  • Re: Checking for a keypress on Linux ?????
    ... >polling for a keypress on the keyboard. ... the short delay in kbhit() ... a blocking single character input from stdin ... int getch; ...
    (comp.os.linux.development.apps)
  • Re: In Word, how can I place a bar above a letter to show a mean?
    ... Combining Diacritic Tilde was not positioned properly); ... most certainly is far more convenient to assign a keyboard shortcut to ... It is of course "impossible" for me to create a macro, ... keyboard short cut for every possilble keyboard character, ...
    (microsoft.public.word.docmanagement)
  • Re: Not quite standard... but socially acceptable
    ... screen, a keyboard, and a commandline, then is there any commonly used ... How can I read a single character from the keyboard without ... Concepts such as screens and keyboards are not even ... with the terminal driver modes (CBREAK or RAW under "classic" ...
    (comp.lang.c)