Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1178
  • Last Modified:

Delphi: Catch F8 keypress

Hi all

I have a TOvcPictureField which contains a date. I want to be able to change the date up and down by pressing the F7 and F8 buttons when the field is in focus. I can do it with the '+' and '-' keys using this code:

Case Key of
    '+' : edtFromDate.AsDateTime:=edtFromDate.AsDateTime+1;
    '-' : edtFromDate.AsDateTime:=edtFromDate.AsDateTime-1;
    else

But I can't find out what the code for the F7 and F8 keys are. Can anyone help?

Regards
Søren Augustesen
0
poultarp
Asked:
poultarp
  • 2
3 Solutions
 
CausalityCommented:

F7  is 118
F8  is 119
0
 
CausalityCommented:
Case Key of
    chr(118) : edtFromDate.AsDateTime:=edtFromDate.AsDateTime+1;
    chr(119) : edtFromDate.AsDateTime:=edtFromDate.AsDateTime-1;
0
 
Geert GruwezOracle dbaCommented:
this gets passed with the keydown event, not keypress event
in the OnKeyDown (or OnKeyUp)

from windows unit

  VK_F7 = 118;
  VK_F8 = 119;

procedure TForm1.cbbAccountKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  case Key of
    VK_F7: edtFromDate.AsDateTime:=edtFromDate.AsDateTime+1; // F7 down
    VK_F8: edtFromDate.AsDateTime:=edtFromDate.AsDateTime-1; // F8 down
  end;    
end;
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now