GoToLine.pas 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. unit GoToLine;
  2. interface
  3. uses
  4. Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  5. Dialogs, StdCtrls;
  6. type
  7. TfrmGotoLine = class(TForm)
  8. Label1: TLabel;
  9. txtLineNumber: TEdit;
  10. btnOK: TButton;
  11. btnCancel: TButton;
  12. procedure btnOKClick(Sender: TObject);
  13. procedure txtLineNumberKeyPress(Sender: TObject; var Key: Char);
  14. procedure FormCreate(Sender: TObject);
  15. private
  16. { Private declarations }
  17. public
  18. { Public declarations }
  19. LineNumber: Integer;
  20. end;
  21. var
  22. frmGotoLine: TfrmGotoLine;
  23. implementation
  24. {$R *.dfm}
  25. procedure TfrmGotoLine.btnOKClick(Sender: TObject);
  26. begin
  27. if txtLineNumber.Text <> '' then
  28. begin
  29. LineNumber := StrToInt(txtLineNumber.Text);
  30. end
  31. else
  32. begin
  33. ModalResult := mrNone;
  34. Application.MessageBox('Please enter a line number.', 'LuaEdit', MB_OK+MB_ICONERROR);
  35. end;
  36. end;
  37. procedure TfrmGotoLine.txtLineNumberKeyPress(Sender: TObject; var Key: Char);
  38. begin
  39. if ((not (Ord(Key) in [48..57])) and (not (Ord(Key) = 8))) then
  40. Key := Char(0);
  41. end;
  42. procedure TfrmGotoLine.FormCreate(Sender: TObject);
  43. begin
  44. txtLineNumber.Text := '';
  45. end;
  46. end.