Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit DeleteElementsUnit;
- interface
- uses
- Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
- Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.Menus, Vcl.StdCtrls;
- type
- TDeleteElementsForm = class(TForm)
- NumberEdit: TEdit;
- IndexEdit: TEdit;
- DeleteBtn: TButton;
- MainMenu: TMainMenu;
- NumberLabel: TLabel;
- IndexLabel: TLabel;
- Instruction: TMenuItem;
- procedure FormShow(Sender: TObject);
- procedure DeleteBtnClick(Sender: TObject);
- procedure IndexEditChange(Sender: TObject);
- procedure NumberEditChange(Sender: TObject);
- procedure NumberEditKeyPress(Sender: TObject; var Key: Char);
- procedure IndexEditKeyPress(Sender: TObject; var Key: Char);
- procedure InstructionClick(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- DeleteElementsForm: TDeleteElementsForm;
- implementation
- {$R *.dfm}
- Uses
- MainUnit, LinkedListUnit;
- procedure TDeleteElementsForm.DeleteBtnClick(Sender: TObject);
- begin
- TListOperations.delete(Header, StrToInt(IndexEdit.Text), StrToInt(NumberEdit.Text));
- IndexEdit.Text := '';
- NumberEdit.Text := '';
- Main.ListMemo.Text := '';
- end;
- procedure TDeleteElementsForm.FormShow(Sender: TObject);
- begin
- IndexEdit.Text := '';
- NumberEdit.Text := '';
- SystemParametersInfo(SPI_SETBEEP, 0, nil, SPIF_SENDWININICHANGE);
- end;
- procedure TDeleteElementsForm.IndexEditChange(Sender: TObject);
- begin
- if IndexEdit.Text <> '' then
- DeleteBtn.Enabled := true
- else
- DeleteBtn.Enabled := false;
- end;
- procedure TDeleteElementsForm.IndexEditKeyPress(Sender: TObject; var Key: Char);
- begin
- if (IndexEdit.Text <> '') and (Key = #13) then
- DeleteBtnClick(Sender);
- if (IndexEdit.Text = '0') and (Key <> #08) then
- Key := #0;
- end;
- procedure TDeleteElementsForm.InstructionClick(Sender: TObject);
- var
- Separator: String;
- begin
- Separator := #13#10;
- MessageDlg('Нужно ввести числа в диапазоне 0..100.', mtInformation, [mbOK], 0);
- end;
- procedure TDeleteElementsForm.NumberEditChange(Sender: TObject);
- begin
- if NumberEdit.Text <> '' then
- DeleteBtn.Enabled := true
- else
- DeleteBtn.Enabled := false;
- end;
- procedure TDeleteElementsForm.NumberEditKeyPress(Sender: TObject;
- var Key: Char);
- begin
- if (NumberEdit.Text <> '') and (Key = #13) then
- DeleteBtnClick(Sender);
- if (NumberEdit.Text = '0') and (Key <> #08) then
- Key := #0;
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement