Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit DeleteRef;
- interface
- uses
- Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
- Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;
- type
- TDeleteForm = class(TForm)
- ComboBox1: TComboBox;
- Button1: TButton;
- procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
- procedure ComboBox1DropDown(Sender: TObject);
- procedure ComboBox1Click(Sender: TObject);
- procedure Button1Click(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- DeleteForm: TDeleteForm;
- DeleteIndex: Integer;
- implementation
- Uses
- Base, ChangeMenu, Add, Menu, Change;
- {$R *.dfm}
- procedure TDeleteForm.Button1Click(Sender: TObject);
- var
- i: Integer;
- Temp: TRef;
- begin
- seek(MyFile, DeleteIndex - 1);
- for i := DeleteIndex - 1 to FileSize(MyFile) - 2 do
- begin
- seek(MyFile, i + 1);
- read(MyFile, Temp);
- seek(MyFile, i);
- Write(MyFile, Temp);
- end;
- seek(MyFile, FileSize(MyFile) - 1);
- truncate(MyFile);
- Reset(MyFile);
- i := 0;
- While not eof(MyFile) do
- begin
- Read(MyFile, Ref[i]);
- Inc(i);
- end;
- n := i;
- ComboBox1.Clear;
- DeleteForm.Hide;
- BaseForm.Show;
- end;
- procedure TDeleteForm.ComboBox1Click(Sender: TObject);
- begin
- Button1.Enabled := True;
- DeleteIndex := ComboBox1.Items.IndexOf(ComboBox1.Text) + 1;
- end;
- procedure TDeleteForm.ComboBox1DropDown(Sender: TObject);
- var
- i: Integer;
- begin
- ComboBox1.Clear;
- for i := 0 to n - 1 do
- ComboBox1.Items.Add(Ref[i].Topic);
- end;
- procedure TDeleteForm.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
- begin
- Button1.Enabled := False;
- ComboBox1.Clear;
- BaseForm.Show;
- MenuForm.Hide;
- ChangeMenuForm.Hide;
- AddForm.Hide;
- DeleteForm.Hide;
- ChangeForm.Hide;
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement