[Lazarus] Formkeydown

2015-06-12 Thread Larry Dalton
The following worked fine in Delphi. I can't get it to work in Lazarus.
Tips, please!


  procedure FormKeyDown(Sender: TObject; var Key: Word;

  Shift: TShiftState);

  const FunctionKeys:array[vk_f1..vk_f12] of string[3]=

('F1','F2','F3','F4','F5','F6','F7','F8','F9','F10','F11','F12');





procedure TMain_Form.FormKeyDown(Sender: TObject; var Key: Word;

  Shift: TShiftState);

  var show_string:string;

begin

str(key,show_string);

If messagedlg('Key
Pressed='+show_string,mtconfirmation,[mbok,mbabort],0)=mrabort then halt;

if Key=vk_f1 then agentbuttonclick(application);

if Key=vk_f2 then custom_form.CreateCar('Cars');

if Key=vk_f3 then custom_form.CreateDeal('Deal');

if Key=vk_f4 then f4panelclick(application);

if key=vk_f5 then custom_form.CreateAgent('Insurance Agent');

if key=vk_f6 then custom_form.CreatePreset('Presets');

if key=vk_f7 then custom_form.CreatePrinter('Print Forms');

if key=vk_f8 then begin
custom_form.F8PanelClick(application);top:=0;left:=0;vertscrollbar.Position:=0;end;

if key=vk_f9 then custom_form.F9Panelclick(application);

if key=vk_f10 then sendnamebuttonclick(application);

if key=vk_home then begin

if messagedlg('Home Key Pressed',mtconfirmation,[mbok],0)=mrok then

top:=0;left:=0;vertscrollbar.Position:=0;

horzscrollbar.Position:=0; }





end;
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Formkeydown

2015-06-12 Thread Jürgen Hestermann

Am 2015-06-12 um 15:08 schrieb Larry Dalton:
 The following worked fine in Delphi. I can't get it to work in Lazarus. Tips, 
please!
What is the problem?

 const FunctionKeys:array[vk_f1..vk_f12] of string[3]= 
('F1','F2','F3','F4','F5','F6','F7','F8','F9','F10','F11','F12');
Where do you use FunctionKeys?

 if messagedlg('Home Key Pressed',mtconfirmation,[mbok],0)=mrok then
top:=0;left:=0;vertscrollbar.Position:=0;
What is intended here? Only the first statement (top:=0) is omitted when the 
IF statement is false.
All others are executed in all cases.

 horzscrollbar.Position:=0; }
What comment ends here?


Why not use a case statement instead of the many IF statements?
For example:

---
Case Key of
   vk_f1 : agentbuttonclick(application);
   vk_f2 : custom_form.CreateCar('Cars');
   vk_f3 : custom_form.CreateDeal('Deal');
   vk_f4 : f4panelclick(application);
   vk_f5 : custom_form.CreateAgent('Insurance Agent');
   vk_f6 : custom_form.CreatePreset('Presets');
   vk_f7 : custom_form.CreatePrinter('Print Forms');
   vk_f8 : begin 
custom_form.F8PanelClick(application);top:=0;left:=0;vertscrollbar.Position:=0;end;
   vk_f9 : custom_form.F9Panelclick(application);
   vk_f10 : sendnamebuttonclick(application);
   vk_home :
  begin
  if messagedlg('Home Key Pressed',mtconfirmation,[mbok],0)=mrok then
 top:=0;
  left:=0;
  vertscrollbar.Position:=0;
  horzscrollbar.Position:=0;
  end;
   end; // of case


--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Formkeydown

2015-06-12 Thread Larry Dalton
Will try that, but first problem is nothing happens when key pressed

Sent from my iPhone

 On Jun 12, 2015, at 11:02, Jürgen Hestermann juergen.hesterm...@gmx.de 
 wrote:
 
 Am 2015-06-12 um 15:08 schrieb Larry Dalton:
  The following worked fine in Delphi. I can't get it to work in Lazarus. 
  Tips, please!
 What is the problem?
 
  const FunctionKeys:array[vk_f1..vk_f12] of string[3]= 
  ('F1','F2','F3','F4','F5','F6','F7','F8','F9','F10','F11','F12');
 Where do you use FunctionKeys?
 
  if messagedlg('Home Key Pressed',mtconfirmation,[mbok],0)=mrok then
 top:=0;left:=0;vertscrollbar.Position:=0;
 What is intended here? Only the first statement (top:=0) is omitted when 
 the IF statement is false.
 All others are executed in all cases.
 
  horzscrollbar.Position:=0; }
 What comment ends here?
 
 
 Why not use a case statement instead of the many IF statements?
 For example:
 
 ---
 Case Key of
   vk_f1 : agentbuttonclick(application);
   vk_f2 : custom_form.CreateCar('Cars');
   vk_f3 : custom_form.CreateDeal('Deal');
   vk_f4 : f4panelclick(application);
   vk_f5 : custom_form.CreateAgent('Insurance Agent');
   vk_f6 : custom_form.CreatePreset('Presets');
   vk_f7 : custom_form.CreatePrinter('Print Forms');
   vk_f8 : begin 
 custom_form.F8PanelClick(application);top:=0;left:=0;vertscrollbar.Position:=0;end;
   vk_f9 : custom_form.F9Panelclick(application);
   vk_f10 : sendnamebuttonclick(application);
   vk_home :
  begin
  if messagedlg('Home Key Pressed',mtconfirmation,[mbok],0)=mrok then
 top:=0;
  left:=0;
  vertscrollbar.Position:=0;
  horzscrollbar.Position:=0;
  end;
   end; // of case
 
 
 --
 ___
 Lazarus mailing list
 Lazarus@lists.lazarus.freepascal.org
 http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Formkeydown

2015-06-12 Thread Larry Dalton
I forgot to include that this is on Windows 7 platform


Sent from my iPhone

 On Jun 12, 2015, at 11:02, Jürgen Hestermann juergen.hesterm...@gmx.de 
 wrote:
 
 Am 2015-06-12 um 15:08 schrieb Larry Dalton:
  The following worked fine in Delphi. I can't get it to work in Lazarus. 
  Tips, please!
 What is the problem?
 
  const FunctionKeys:array[vk_f1..vk_f12] of string[3]= 
  ('F1','F2','F3','F4','F5','F6','F7','F8','F9','F10','F11','F12');
 Where do you use FunctionKeys?
 
  if messagedlg('Home Key Pressed',mtconfirmation,[mbok],0)=mrok then
 top:=0;left:=0;vertscrollbar.Position:=0;
 What is intended here? Only the first statement (top:=0) is omitted when 
 the IF statement is false.
 All others are executed in all cases.
 
  horzscrollbar.Position:=0; }
 What comment ends here?
 
 
 Why not use a case statement instead of the many IF statements?
 For example:
 
 ---
 Case Key of
   vk_f1 : agentbuttonclick(application);
   vk_f2 : custom_form.CreateCar('Cars');
   vk_f3 : custom_form.CreateDeal('Deal');
   vk_f4 : f4panelclick(application);
   vk_f5 : custom_form.CreateAgent('Insurance Agent');
   vk_f6 : custom_form.CreatePreset('Presets');
   vk_f7 : custom_form.CreatePrinter('Print Forms');
   vk_f8 : begin 
 custom_form.F8PanelClick(application);top:=0;left:=0;vertscrollbar.Position:=0;end;
   vk_f9 : custom_form.F9Panelclick(application);
   vk_f10 : sendnamebuttonclick(application);
   vk_home :
  begin
  if messagedlg('Home Key Pressed',mtconfirmation,[mbok],0)=mrok then
 top:=0;
  left:=0;
  vertscrollbar.Position:=0;
  horzscrollbar.Position:=0;
  end;
   end; // of case
 
 
 --
 ___
 Lazarus mailing list
 Lazarus@lists.lazarus.freepascal.org
 http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Formkeydown

2015-06-12 Thread leledumbo
 Will try that, but first problem is nothing happens when key pressed 

Did you set KeyPreview to true?



--
View this message in context: 
http://free-pascal-lazarus.989080.n3.nabble.com/Lazarus-Formkeydown-tp4042578p4042588.html
Sent from the Free Pascal - Lazarus mailing list archive at Nabble.com.

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus