Advertisement
MadCortez

Untitled

Mar 23rd, 2021
392
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 1.89 KB | None | 0 0
  1. unit Menu;
  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;
  8.  
  9. type
  10.   TMenuForm = class(TForm)
  11.     Button1: TButton;
  12.     Button2: TButton;
  13.     OpenDialog1: TOpenDialog;
  14.     procedure Button1Click(Sender: TObject);
  15.     procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
  16.     procedure Button2Click(Sender: TObject);
  17.     procedure FormCreate(Sender: TObject);
  18.   private
  19.     { Private declarations }
  20.   public
  21.     { Public declarations }
  22.   end;
  23.   TRef = Record
  24.       Topic: String[25];
  25.       Author: String[20];
  26.       Str: Integer;
  27.       Date: String[10];
  28.   End;
  29.  
  30. var
  31.   MenuForm: TMenuForm;
  32.   Ref: array of TRef;
  33.   MyFile: File of TRef;
  34.   n: Integer;
  35.  
  36. implementation
  37.  
  38. Uses
  39.    Base, ChangeMenu, Add, DeleteRef, Change;
  40.  
  41. {$R *.dfm}
  42.  
  43. procedure TMenuForm.Button1Click(Sender: TObject);
  44. begin
  45.    BaseForm.Show;
  46.    MenuForm.Hide;
  47. end;
  48.  
  49. procedure TMenuForm.Button2Click(Sender: TObject);
  50. var
  51.    i: Integer;
  52. begin
  53.    i := 0;
  54.    if OpenDialog1.Execute then
  55.    begin
  56.       AssignFile(MyFile, OpenDialog1.FileName);
  57.       Reset(MyFile);
  58.       SetLength(Ref, FileSize(MyFile));
  59.       While not eof(MyFile) do
  60.       begin
  61.          Read(MyFile, Ref[i]);
  62.          Inc(i);
  63.       end;
  64.       n := i;
  65.    end;
  66.    Button1.Enabled := True;
  67. end;
  68.  
  69. procedure TMenuForm.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
  70. begin
  71.    CanClose := MessageDlg('Вы уверены, что хотите выйти из программы?' +
  72.       #10#13 + 'Все несохраненные данные будут утеряны.',
  73.       mtConfirmation, [mbYes, mbNo], 0) = mrYes;
  74.    ChangeMenuForm.Close;
  75.    AddForm.Close;
  76.    DeleteForm.Close;
  77.    ChangeForm.Close;
  78. end;
  79.  
  80. procedure TMenuForm.FormCreate(Sender: TObject);
  81. begin
  82.    n := 0;
  83. end;
  84.  
  85. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement