Solved

Delphi: Catch F8 keypress

Posted on 2009-06-30
3
1,138 Views
Last Modified: 2012-05-07
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
Comment
Question by:poultarp
  • 2
3 Comments
 
LVL 2

Accepted Solution

by:
Causality earned 334 total points
ID: 24743051

F7  is 118
F8  is 119
0
 
LVL 2

Assisted Solution

by:Causality
Causality earned 334 total points
ID: 24743058
Case Key of
    chr(118) : edtFromDate.AsDateTime:=edtFromDate.AsDateTime+1;
    chr(119) : edtFromDate.AsDateTime:=edtFromDate.AsDateTime-1;
0
 
LVL 36

Assisted Solution

by:Geert Gruwez
Geert Gruwez earned 166 total points
ID: 24744776
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This video discusses moving either the default database or any database to a new volume.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now