Advertisement
believe_me

Untitled

Mar 27th, 2022
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 2.59 KB | None | 0 0
  1. unit DeleteElementsUnit;
  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.Menus, Vcl.StdCtrls;
  8.  
  9. type
  10.   TDeleteElementsForm = class(TForm)
  11.     NumberEdit: TEdit;
  12.     IndexEdit: TEdit;
  13.     DeleteBtn: TButton;
  14.     MainMenu: TMainMenu;
  15.     NumberLabel: TLabel;
  16.     IndexLabel: TLabel;
  17.     Instruction: TMenuItem;
  18.     procedure FormShow(Sender: TObject);
  19.     procedure DeleteBtnClick(Sender: TObject);
  20.     procedure IndexEditChange(Sender: TObject);
  21.     procedure NumberEditChange(Sender: TObject);
  22.     procedure NumberEditKeyPress(Sender: TObject; var Key: Char);
  23.     procedure IndexEditKeyPress(Sender: TObject; var Key: Char);
  24.     procedure InstructionClick(Sender: TObject);
  25.   private
  26.     { Private declarations }
  27.   public
  28.     { Public declarations }
  29.   end;
  30.  
  31. var
  32.   DeleteElementsForm: TDeleteElementsForm;
  33.  
  34. implementation
  35.  
  36. {$R *.dfm}
  37.  
  38.  
  39. Uses
  40.      MainUnit, LinkedListUnit;
  41.  
  42.  
  43. procedure TDeleteElementsForm.DeleteBtnClick(Sender: TObject);
  44.  
  45. begin
  46.     TListOperations.delete(Header, StrToInt(IndexEdit.Text), StrToInt(NumberEdit.Text));
  47.     IndexEdit.Text := '';
  48.     NumberEdit.Text := '';
  49.     Main.ListMemo.Text := '';
  50. end;
  51.  
  52. procedure TDeleteElementsForm.FormShow(Sender: TObject);
  53. begin
  54.     IndexEdit.Text := '';
  55.     NumberEdit.Text := '';
  56.     SystemParametersInfo(SPI_SETBEEP, 0, nil, SPIF_SENDWININICHANGE);
  57. end;
  58.  
  59. procedure TDeleteElementsForm.IndexEditChange(Sender: TObject);
  60.  
  61. begin
  62.     if IndexEdit.Text <> '' then
  63.         DeleteBtn.Enabled := true
  64.     else
  65.         DeleteBtn.Enabled := false;
  66. end;
  67.  
  68. procedure TDeleteElementsForm.IndexEditKeyPress(Sender: TObject; var Key: Char);
  69.  
  70. begin
  71.     if (IndexEdit.Text <> '') and (Key = #13) then
  72.         DeleteBtnClick(Sender);
  73.     if (IndexEdit.Text = '0') and (Key <> #08) then
  74.         Key := #0;
  75. end;
  76.  
  77. procedure TDeleteElementsForm.InstructionClick(Sender: TObject);
  78.  
  79. var
  80.     Separator: String;
  81.  
  82. begin
  83.     Separator := #13#10;
  84.     MessageDlg('Нужно ввести числа в диапазоне 0..100.', mtInformation, [mbOK], 0);
  85. end;
  86.  
  87. procedure TDeleteElementsForm.NumberEditChange(Sender: TObject);
  88.  
  89. begin
  90.     if NumberEdit.Text <> '' then
  91.         DeleteBtn.Enabled := true
  92.     else
  93.         DeleteBtn.Enabled := false;
  94. end;
  95.  
  96. procedure TDeleteElementsForm.NumberEditKeyPress(Sender: TObject;
  97.   var Key: Char);
  98.  
  99. begin
  100.     if (NumberEdit.Text <> '') and (Key = #13) then
  101.         DeleteBtnClick(Sender);
  102.     if (NumberEdit.Text = '0') and (Key <> #08) then
  103.         Key := #0;
  104. end;
  105.  
  106. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement