Saturday, May 30, 2020

Make The Enter Key Work Like Tab in Delphi Applications

Make The Enter Key Work Like Tab in Delphi Applications We realize that, by and large, squeezing the Tab key moves the info center to next control and Shift-Tab to past in the tab request of the structure. When working with Windows applications, a few clients naturally expect the Enter key to carry on like a Tab key. There is a great deal of outsider code for executing better information section handling in Delphi. Here are a couple of the best techniques out there (with certain adjustments). Models underneath are composed with the suspicion that there is no default button on the structure. At the point when your structure contains a catch whose Default property is set to True, squeezing Enter at runtime executes any code contained in the catches OnClick occasion handler. Enter as Tab The following code causes Enter to carry on like Tab, and ShiftEnter like ShiftTab: ~~~~~~~~~~~~~~~~~~~~~~~~~procedure TForm1.Edit1KeyPress (Sender: TObject; var Key: Char) ;beginâ â If Key #13 Then Beginâ â â If HiWord(GetKeyState(VK_SHIFT)) 0 thenâ â â â SelectNext(Sender as TWinControl,False,True)   elseâ â â â SelectNext(Sender as TWinControl,True,True) ; â â â Key : #0â â end;end;~~~~~~~~~~~~~~~~~~~~~~~~~ in DBGrid In the event that you need to have comparable Enter (ShiftEnter) preparing in DBGrid: ~~~~~~~~~~~~~~~~~~~~~~~~~procedure TForm1.DBGrid1KeyPress (Sender: TObject; var Key: Char) ;beginâ â If Key #13 Then Beginâ â â If HiWord(GetKeyState(VK_SHIFT)) 0 then beginâ â â â with (Sender as TDBGrid) doâ â â â if selectedindex 0 thenâ â â â â selectedindex : selectedindex - 1â â â â else beginâ â â â â DataSource.DataSet.Prior;     selectedindex : fieldcount - 1;â â â â end;â â â end else beginâ â â â with (Sender as TDBGrid) doâ â â â if selectedindex (fieldcount - 1) thenâ â â â â selectedindex : selectedindex 1â â â â else beginâ â â â â DataSource.DataSet.Next;     selectedindex : 0;â â â â end;â â Key : #0â â end;end;~~~~~~~~~~~~~~~~~~~~~~~~~ More Info on Delphi Applications Console Symphony Get acquainted with the OnKeyDown, OnKeyUp, and onKeyPress occasion techniques to react to different key activities or handle and procedure ASCII characters alongside other specific reason keys. What Does #13#10 Depend on, in Delphi Code? If you are thinking about what those characters rely on, heres the appropriate response.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.