Solved

Delphi: Catch F8 keypress

Posted on 2009-06-30
3
1,140 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 37

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Convert Jpg /PNG To GIF 5 120
Delphi - replicating a form 8 65
Delphi selector screen 2 69
Graphics32 under Delphi 10.1 Berlin 2 36
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

910 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

19 Experts available now in Live!

Get 1:1 Help Now