ErrorLookup.pas 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. unit ErrorLookup;
  2. interface
  3. uses
  4. Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  5. Dialogs, StdCtrls, ExtCtrls;
  6. type
  7. TfrmErrorLookup = class(TForm)
  8. Panel1: TPanel;
  9. txtErrorLookup: TEdit;
  10. btnLookUp: TButton;
  11. btnClose: TButton;
  12. Panel2: TPanel;
  13. memoErrorLookup: TMemo;
  14. procedure FormShow(Sender: TObject);
  15. procedure btnLookUpClick(Sender: TObject);
  16. procedure txtErrorLookupKeyPress(Sender: TObject; var Key: Char);
  17. procedure btnCloseClick(Sender: TObject);
  18. private
  19. { Private declarations }
  20. public
  21. { Public declarations }
  22. end;
  23. var
  24. frmErrorLookup: TfrmErrorLookup;
  25. implementation
  26. uses Math;
  27. {$R *.dfm}
  28. procedure TfrmErrorLookup.FormShow(Sender: TObject);
  29. begin
  30. memoErrorLookup.Lines.Clear;
  31. txtErrorLookup.Text := '';
  32. end;
  33. procedure TfrmErrorLookup.btnLookUpClick(Sender: TObject);
  34. begin
  35. try
  36. memoErrorLookup.Lines.Clear;
  37. if SysErrorMessage(StrToInt(txtErrorLookup.Text)) <> '' then
  38. memoErrorLookup.Text := SysErrorMessage(StrToInt(txtErrorLookup.Text))
  39. else
  40. Application.MessageBox('The specified message number does not represent a Windows NT message.', 'LuaEdit', MB_OK+MB_ICONERROR);
  41. except
  42. Application.MessageBox(PChar('The expression "'+txtErrorLookup.Text+'" is not numeric.'), 'LuaEdit', MB_OK+MB_ICONERROR);
  43. txtErrorLookup.SetFocus;
  44. end;
  45. end;
  46. procedure TfrmErrorLookup.txtErrorLookupKeyPress(Sender: TObject; var Key: Char);
  47. begin
  48. if not (Key in ['0'..'9', #8]) then
  49. Key := #0;
  50. end;
  51. procedure TfrmErrorLookup.btnCloseClick(Sender: TObject);
  52. begin
  53. Self.Close;
  54. end;
  55. end.