Главная страница | назад





Article #16435: How can I detect if a given key was pressed during application during startup?

 Question and Answer Database

FAQ1435D.txt   How can I detect if a given key was pressed during application during startup?
Category   :Windows API
Platform    :All
Product    :All 32 bit  

Question:
How can I detect if a given key was pressed during application
startup?

Answer:
Use the Windows API function GetKeyState() to determine if a key is
pressed in the main project source. To get to the main project's
source file, select from the IDE's main menu, select
"View">>"ProjectSource".

Example:

program Project1;

uses
  Windows,
  Forms,
  Unit1 in 'Unit1.pas' {Form1};

{$R *.RES}

begin
  if GetKeyState(vk_F8) < 1 then
   MessageBox(0, 'F8 was pressed during startup', 'MyApp', mb_ok);
  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  Application.Run;
end.

7/16/98 4:31:28 PM
 

Last Modified: 01-SEP-99