Advertisement
believe_me

Untitled

Mar 27th, 2022
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 1.92 KB | None | 0 0
  1. unit AddElementsUnit;
  2.  
  3. interface
  4.  
  5. uses
  6.   Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  7.   Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.Menus, System.RegularExpressions, System.Math;
  8.  
  9. type
  10.   TAddElementsForm = class(TForm)
  11.     AddBtn: TButton;
  12.     ElementEdit: TEdit;
  13.     InstructionMenu: TMainMenu;
  14.     Instruction: TMenuItem;
  15.     Label1: TLabel;
  16.     procedure AddBtnClick(Sender: TObject);
  17.     procedure ElementEditChange(Sender: TObject);
  18.     procedure ElementEditKeyPress(Sender: TObject; var Key: Char);
  19.     procedure FormShow(Sender: TObject);
  20.     procedure InstructionClick(Sender: TObject);
  21.   private
  22.     { Private declarations }
  23.   public
  24.     { Public declarations }
  25.   end;
  26.  
  27. var
  28.   AddElementsForm: TAddElementsForm;
  29.  
  30. implementation
  31.  
  32. {$R *.dfm}
  33.  
  34. Uses
  35.      MainUnit, LinkedListUnit;
  36.  
  37.  
  38. procedure  TAddElementsForm.ElementEditChange(Sender: TObject);
  39.  
  40. begin
  41.     if ElementEdit.Text <> '' then
  42.         AddBtn.Enabled := true
  43.     else
  44.         AddBtn.Enabled := false;
  45. end;
  46.  
  47.  
  48. procedure TAddElementsForm.ElementEditKeyPress(Sender: TObject; var Key: Char);
  49. begin
  50.     if (ElementEdit.Text <> '') and (Key = #13) then
  51.         AddBtnClick(Sender);
  52.     if (ElementEdit.Text = '0') and (Key <> #08) then
  53.         Key := #0;
  54. end;
  55.  
  56. procedure TAddElementsForm.FormShow(Sender: TObject);
  57. begin
  58.     ElementEdit.Text := '';
  59.     SystemParametersInfo(SPI_SETBEEP, 0, nil, SPIF_SENDWININICHANGE);
  60. end;
  61.  
  62. procedure TAddElementsForm.InstructionClick(Sender: TObject);
  63.  
  64. var
  65.     Separator: String;
  66.  
  67. begin
  68.     Separator := #13#10;
  69.     MessageDlg('Нужно ввессти число в диапазон 0..99.', mtInformation, [mbOK], 0);
  70. end;
  71.  
  72.  
  73. procedure TAddElementsForm.AddBtnClick(Sender: TObject);
  74.  
  75. begin
  76.     TListOperations.push(Header, StrToInt(ElementEdit.Text));
  77.     ElementEdit.Text := '';
  78.     Main.ListMemo.Text := '';
  79. end;
  80.  
  81.  
  82. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement