[Lazarus] Formkeydown

Jürgen Hestermann juergen.hestermann at gmx.de
Fri Jun 12 18:02:13 CEST 2015


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





More information about the Lazarus mailing list