Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2015-06

Formkeydown

6 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

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;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20150612/baad37c4/attachment.html>

Reply by email

Jürgen Hestermann
to Larry Dalton
Larry Dalton wrote
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

Reply by email

Larry Dalton
to Jürgen Hestermann

Will try that, but first problem is nothing happens when key pressed

Sent from my iPhone

Show quoted text 49 lines
On Jun 12, 2015, at 11:02, J?rgen Hestermann 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 http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email

Larry Dalton
to Jürgen Hestermann: What is the problem? Where do you use FunctionKeys? What is intended here? Only the first…

I forgot to include that this is on Windows 7 platform

Sent from my iPhone

Show quoted text 49 lines
On Jun 12, 2015, at 11:02, J?rgen Hestermann 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 http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email

Larry Dalton
to leledumbo

No. That fixed it. Thanks!

Sent from my iPhone

leledumbo wrote 15 lines
> 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 . -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email