Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Unit form23;
- Interface
- Uses
- Math,
- Vcl.ExtDlgs,
- Vcl.Dialogs,
- Vcl.Menus,
- Vcl.StdCtrls,
- Vcl.Controls,
- Winapi.Windows,
- Winapi.Messages,
- System.SysUtils,
- System.Variants,
- System.Classes,
- Vcl.Graphics,
- Vcl.Forms,
- Unit23_1,
- Unit23_2,
- Vcl.ComCtrls,
- Vcl.Grids;
- Type
- TErrorCode = (EcCorrect, EcInvalid_Value, EcInvalid_Range, EcNot_Readable, EcNot_Writeable, EcIncorrect_Amount_lines);
- Type
- TArr = Array Of Array Of Array Of Integer;
- TMainForm = Class(TForm)
- MainMenu: TMainMenu;
- FileMenu: TMenuItem;
- OpenMenu: TMenuItem;
- SaveMenu: TMenuItem;
- ExitMenu: TMenuItem;
- InstructionMenu: TMenuItem;
- DeveloperMenu: TMenuItem;
- TaskLabel: TLabel;
- NEdit: TEdit;
- ResultButton: TButton;
- MyOpenTextFileDialog: TOpenTextFileDialog;
- MySaveTextFileDialog: TSaveTextFileDialog;
- RLabel: TLabel;
- XGrid: TStringGrid;
- Label1: TLabel;
- PopupMenu1: TPopupMenu;
- Label2: TLabel;
- MEdit: TEdit;
- KEdit: TEdit;
- Label3: TLabel;
- ResultMemo: TMemo;
- Procedure NEditKeyDown(Sender: TObject; Var Key: Word; Shift: TShiftState);
- Procedure InstructionMenuClick(Sender: TObject);
- Procedure DeveloperMenuClick(Sender: TObject);
- Procedure OpenMenuClick(Sender: TObject);
- Procedure SaveMenuClick(Sender: TObject);
- Procedure ResultButtonClick(Sender: TObject);
- Procedure ExitMenuClick(Sender: TObject);
- procedure CalcResult(Sender: TObject);
- Procedure FormCloseQuery(Sender: TObject; Var CanClose: Boolean);
- Function CheckInputFields(Sender: TObject; CurEdit: TEdit; CurStringGrid: TStringGrid): Boolean;
- Procedure FileMenuClick(Sender: TObject);
- Procedure CheckEdit(Sender: TObject; Var Key: Char; CurEdit: TEdit);
- Procedure SelectEdit(Sender: TObject; Var Key: Word);
- Procedure FormCreate(Sender: TObject);
- Function CheckCells(CurStringGrid: TStringGrid): Boolean;
- Procedure NEditKeyPress(Sender: TObject; Var Key: Char);
- Procedure XGridSetEditText(Sender: TObject; ACol, ARow: Integer; Const Value: String);
- Procedure NEditChange(Sender: TObject);
- Procedure GridCheck(Sender: TObject);
- Procedure XGridKeyDown(Sender: TObject; Var Key: Word; Shift: TShiftState);
- Procedure SelectEdit2(Sender: TObject; Var Key: Word; CurEdit: TEdit);
- Procedure MEditKeyDown(Sender: TObject; Var Key: Word; Shift: TShiftState);
- Procedure MEditKeyPress(Sender: TObject; Var Key: Char);
- Procedure MEditChange(Sender: TObject);
- Procedure KEditChange(Sender: TObject);
- Procedure KEditKeyPress(Sender: TObject; Var Key: Char);
- Procedure KEditKeyDown(Sender: TObject; Var Key: Word; Shift: TShiftState);
- Function EnterArr(): TArr;
- Procedure ColorizeColumn(StringGrid: TStringGrid; ColumnIndex: Integer; Color: TColor);
- Procedure XGridDrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState);
- Private
- { Private declarations }
- Public
- { Public declarations }
- End;
- Const
- ERRORS: Array [TErrorCode] Of String = ('', 'Некорректный тип данных внутри файла!', 'Значения не попадают в диапазон!',
- 'Файл закрыт для чтения!', 'Файл закрыт для записи!', 'Неверное количество данных в файле');
- BACKSPACE = #8;
- NONE = #0;
- DIGITS = ['0' .. '9'];
- MAX_N = 10;
- MIN_N = 2;
- MAX_X = 1000;
- MIN_X = -1000;
- FACTOR = 1.247;
- Var
- MainForm: TMainForm;
- Implementation
- {$R *.dfm}
- Function IsAbleToReading(Var F: TextFile): TErrorCode;
- Var
- Error: TErrorCode;
- Begin
- Error := EcCorrect;
- Try
- Reset(F);
- CloseFile(F);
- Except
- Error := EcNot_Readable;
- End;
- IsAbleToReading := Error;
- End;
- Function FindChar(MyText: String; MyChar: Char): Boolean;
- Var
- N, I, Counter: Integer;
- Begin
- N := Length(MyText);
- Counter := 0;
- For I := 1 To N Do
- If MyText[I] = MyChar Then
- Inc(Counter);
- If Counter = 0 Then
- FindChar := False
- Else
- FindChar := True;
- End;
- Function CheckUserArea(Num: Integer; Const MAX, MIN: Integer): Boolean;
- Var
- IsCorrect: Boolean;
- Begin
- If (Num < 2) Or (Num > 10) Then
- Begin
- IsCorrect := False;
- End
- Else
- IsCorrect := True;
- CheckUserArea := IsCorrect;
- End;
- Function CheckXArea(Num: Double; Const MAX, MIN: Real): Boolean;
- Var
- IsCorrect: Boolean;
- Begin
- If (Num < MIN) Or (Num > MAX) Then
- Begin
- IsCorrect := False;
- End
- Else
- IsCorrect := True;
- CheckXArea := IsCorrect;
- End;
- Function CheckFileData(Var F: TextFile; N, M, K1: Integer; Var Error: TErrorCode): TErrorCode;
- Var
- KLine: String;
- K: Real;
- Numbers: TArray<String>;
- CountN, CountM, I: Integer;
- Begin
- I := 0;
- CountM := 0;
- While (Error = EcCorrect) And Not EOF(F) Do
- Begin
- Try
- Read(F, KLine);
- Numbers := KLine.Split([' ']);
- Except
- Error := EcInvalid_Value;
- End;
- If (Error = EcCorrect) And (Length(Numbers) <> N * K1) Then
- Begin
- Error := EcIncorrect_Amount_lines;
- End;
- I := 0;
- While (Error = EcCorrect) And (I < (Length(Numbers))) Do
- Begin
- Try
- K := StrToFloat(Numbers[I]);
- Except
- Error := EcInvalid_Value;
- End;
- Inc(I);
- If (Error = EcCorrect) And Not(CheckXArea(K, MAX_X, MIN_X)) Then
- Error := EcInvalid_Range;
- End;
- Inc(CountM);
- Readln(F);
- End;
- If (Error = EcCorrect) And (CountM <> M) Then
- Begin
- Error := EcIncorrect_Amount_lines;
- End;
- CloseFile(F);
- CheckFileData := Error;
- End;
- Function CheckFileData1(Var F: TextFile): TErrorCode;
- Var
- FLine: String;
- I, N, M, J, K1: Integer;
- K, S: Double;
- Error: TErrorCode;
- Begin
- Error := EcCorrect;
- Reset(F);
- For I := 1 To 3 Do
- Begin
- Readln(F, FLine);
- Try
- Begin
- If I = 1 Then
- M := StrToInt(FLine)
- Else
- If I = 2 Then
- N := StrToInt(FLine)
- Else
- K1 := StrToInt(FLine)
- End;
- Except
- Error := EcInvalid_Value;
- End;
- If (Error = EcCorrect) And Not(CheckUserArea(StrToInt(FLine), MAX_N, MIN_N)) Then
- Error := EcInvalid_Range;
- End;
- If Error = EcCorrect Then
- Error := CheckFileData(F, N, M, K1, Error);
- CheckFileData1 := Error;
- End;
- Procedure TMainForm.DeveloperMenuClick(Sender: TObject);
- Var
- DeveloperForm: TDeveloperForm;
- Begin
- DeveloperForm := TDeveloperForm.Create(Self);
- DeveloperForm.ShowModal;
- DeveloperForm.Free;
- End;
- Procedure TMainForm.InstructionMenuClick(Sender: TObject);
- Var
- InstructionForm: TInstructionForm;
- Begin
- InstructionForm := TInstructionForm.Create(Self);
- InstructionForm.ShowModal;
- InstructionForm.Free;
- End;
- Procedure TMainForm.KEditChange(Sender: TObject);
- Var
- I, L, K: Integer;
- Begin
- If (KEdit.Text = '') Then
- Begin
- For I := 0 To XGrid.ColCount - 1 Do
- XGrid.Rows[I].Clear;
- XGrid.ColCount := 0;
- End
- Else
- Begin
- XGrid.ColCount := StrToInt(KEdit.Text) * StrToInt(NEdit.Text);
- End;
- End;
- Procedure TMainForm.KEditKeyDown(Sender: TObject; Var Key: Word; Shift: TShiftState);
- Begin
- SelectEdit2(Sender, Key, KEdit);
- End;
- Procedure TMainForm.KEditKeyPress(Sender: TObject; Var Key: Char);
- Begin
- CheckEdit(Sender, Key, KEdit);
- End;
- Procedure TMainForm.ColorizeColumn(StringGrid: TStringGrid; ColumnIndex: Integer; Color: TColor);
- Var
- RowIndex: Integer;
- Begin
- If (ColumnIndex >= 0) And (ColumnIndex < StringGrid.ColCount) Then
- Begin
- For RowIndex := 0 To StringGrid.RowCount - 1 Do
- Begin
- StringGrid.Canvas.Brush.Color := Color;
- StringGrid.Canvas.FillRect(StringGrid.CellRect(ColumnIndex, RowIndex));
- StringGrid.Canvas.TextRect(StringGrid.CellRect(ColumnIndex, RowIndex), StringGrid.CellRect(ColumnIndex, RowIndex).Left + 2,
- StringGrid.CellRect(ColumnIndex, RowIndex).Top + 2, StringGrid.Cells[ColumnIndex, RowIndex]);
- End;
- End;
- End;
- Procedure TMainForm.NEditChange(Sender: TObject);
- Var
- I: Integer;
- Begin
- If (NEdit.Text = '') Then
- Begin
- For I := 0 To XGrid.ColCount - 1 Do
- XGrid.Rows[I].Clear;
- XGrid.ColCount := 0;
- End
- Else
- { XGrid.ColCount := StrToInt(KEdit.Text)*StrToInt(NEdit.Text); }
- End;
- Procedure TMainForm.MEditChange(Sender: TObject);
- Var
- I: Integer;
- Begin
- If (MEdit.Text = '') Then
- Begin
- For I := 0 To XGrid.RowCount - 1 Do
- XGrid.Rows[I].Clear;
- XGrid.RowCount := 0;
- End
- Else
- XGrid.RowCount := StrToInt(MEdit.Text);
- End;
- Procedure TMainForm.MEditKeyDown(Sender: TObject; Var Key: Word; Shift: TShiftState);
- Begin
- SelectEdit2(Sender, Key, MEdit);
- End;
- Procedure TMainForm.MEditKeyPress(Sender: TObject; Var Key: Char);
- Begin
- CheckEdit(Sender, Key, MEdit);
- End;
- Procedure TMainForm.NEditKeyDown(Sender: TObject; Var Key: Word; Shift: TShiftState);
- Begin
- SelectEdit2(Sender, Key, NEdit);
- End;
- Procedure TMainForm.NEditKeyPress(Sender: TObject; Var Key: Char);
- Begin
- CheckEdit(Sender, Key, NEdit);
- End;
- Procedure TMainForm.OpenMenuClick(Sender: TObject);
- Var
- X1: Real;
- FilePath: String;
- F: TextFile;
- ErrorCode: TErrorCode;
- N1, M1, I, J, K1: Integer;
- N, M, X, K: String;
- Numbers: TArray<String>;
- Begin
- If MyOpenTextFileDialog.Execute Then
- Begin
- FilePath := MyOpenTextFileDialog.FileName;
- AssignFile(F, FilePath);
- ErrorCode := IsAbleToReading(F);
- If ErrorCode = EcCorrect Then
- Begin
- ErrorCode := CheckFileData1(F);
- If ErrorCode <> EcCorrect Then
- Application.MessageBox(PChar(ERRORS[ErrorCode]), 'Ошибка', MB_OK)
- Else
- Begin
- Reset(F);
- Readln(F, M);
- MEdit.Text := M;
- Readln(F, N);
- NEdit.Text := N;
- Readln(F, K);
- KEdit.Text := K;
- N1 := StrToInt(N);
- M1 := StrToInt(M);
- K1 := StrToInt(K);
- For J := 0 To M1 - 1 Do
- Begin
- Read(F, X);
- Numbers := X.Split([' ']);
- For I := 0 To (N1 * K1 - 1) Do
- Begin
- XGrid.Cells[I, J] := Numbers[I];
- End;
- Readln(F);
- End;
- CloseFile(F);
- End;
- End
- Else
- Application.MessageBox(PChar(ERRORS[ErrorCode]), 'Ошибка', MB_OK);
- End;
- End;
- Function TMainForm.EnterArr(): TArr;
- Var
- N, M, K, I, J, L, J1: Integer;
- RArr: Tarr;
- Begin
- N := StrToInt(NEdit.Text);
- M := StrToInt(KEdit.Text);
- K := StrToInt(MEdit.Text);
- SetLength(RArr, K, M, N);
- J1 := 0;
- For L := 0 To K - 1 Do
- Begin
- For I := 0 To M - 1 Do
- Begin
- J := 0;
- while (J<N)do
- Begin
- RArr[L, I, J] := StrToInt(XGrid.Cells[(J+n*L), I]);
- Inc(J);
- End;
- End;
- End;
- EnterArr := RArr;
- End;
- Function DeletBackspace(EditText: String; Var KeyChar: Char): String;
- Begin
- If (KeyChar = BACKSPACE) Then
- DeletBackspace := EditText
- Else
- DeletBackspace := EditText + KeyChar;
- End;
- Procedure TMainForm.CheckEdit(Sender: TObject; Var Key: Char; CurEdit: TEdit);
- Begin
- If Not(Key In DIGITS) And Not(Key = BACKSPACE) Then
- Key := NONE
- Else
- Begin
- If (Length(CurEdit.Text) < 1) And (Key = '0') Then
- Key := NONE;
- If (Length(CurEdit.Text) > 1) And Not(CheckUserArea(StrToInt(DeletBackspace(CurEdit.Text, Key)), MAX_N, MIN_N)) And Not(Key = BACKSPACE) Then
- Key := NONE;
- End;
- End;
- Procedure TMainForm.SelectEdit(Sender: TObject; Var Key: Word);
- Begin
- With XGrid Do
- Begin
- If (Key = VK_RIGHT) Then
- Begin
- If Col < (Colcount - 1) Then
- Col := Col + 1
- Else
- Col := 0;
- Key := 0;
- End
- Else
- Begin
- If (Key = VK_LEFT) Then
- Begin
- If Col > 0 Then
- Col := Col - 1
- Else
- Col := Colcount - 1;
- Key := 0;
- End
- Else
- Begin
- If (Key = VK_Up) Then
- Begin
- If Row > 0 Then
- Row := Row - 1
- Else
- Row := Rowcount - 1;
- Key := 0;
- End
- Else
- Begin
- If (Key = VK_Down) Then
- Begin
- If Row < (Rowcount - 1) Then
- Row := Row + 1
- Else
- Row := 0;
- Key := 0;
- End;
- End;
- End;
- End;
- End;
- End;
- Procedure TMainForm.SelectEdit2(Sender: TObject; Var Key: Word; CurEdit: TEdit);
- Begin
- With XGrid Do
- Begin
- If (Key = VK_RIGHT) Or (Key = VK_LEFT) Then
- XGrid.SetFocus
- Else
- If (Key = VK_Up) Then
- Begin
- SelectNext(CurEdit, True, True);
- End
- Else
- If (Key = VK_Down) Then
- Begin
- SelectNext(CurEdit, True, False);
- End;
- End;
- End;
- Function TMainForm.CheckInputFields(Sender: TObject; CurEdit: TEdit; CurStringGrid: TStringGrid): Boolean;
- Var
- N, M: Byte;
- IsCorrect: Boolean;
- Begin
- IsCorrect := True;
- If (NEdit.Text = '') Or (MEdit.Text = '') Then
- Begin
- IsCorrect := False;
- CurEdit.SetFocus;
- ShowMessage('Введите размер матрицы!');
- End
- Else
- Begin
- N := StrToInt(NEdit.Text);
- M := StrToInt(MEdit.Text);
- If (N < 2) Then
- Begin
- IsCorrect := False;
- CurEdit.Text := '';
- CurEdit.SetFocus;
- ShowMessage('N не может быть меньше 2!');
- End
- Else
- Begin
- If (M < 2) Then
- Begin
- IsCorrect := False;
- CurEdit.Text := '';
- CurEdit.SetFocus;
- ShowMessage('M не может быть меньше 2!');
- End
- End;
- End;
- If Not(CheckCells(XGrid)) And (IsCorrect) Then
- Begin
- IsCorrect := False;
- CurStringGrid.SetFocus;
- ShowMessage('Заполните таблицу до конца!');
- End;
- CheckInputFields := IsCorrect;
- End;
- Procedure TMainForm.XGridDrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState);
- Begin
- Var
- K, I, J, N, I1: Integer;
- Begin
- If (KEdit.Text <> '') And (Medit.Text <> '') And (NEdit.Text <> '') Then
- Begin
- K := StrToInt(KEdit.Text);
- N := StrToInt(NEdit.Text);
- I1 := 0;
- For J := 0 To K - 1 Do
- Begin
- For I := 0 To N - 1 Do
- Begin
- If J Mod 2 = 1 Then
- ColorizeColumn(XGrid, I1, ClRed)
- Else
- If J Mod 2 = 0 Then
- ColorizeColumn(XGrid, I1, ClGreen);
- Inc(I1);
- End;
- End;
- End;
- End;
- End;
- Procedure TMainForm.XGridKeyDown(Sender: TObject; Var Key: Word; Shift: TShiftState);
- Begin
- SelectEdit(Sender, Key)
- End;
- Procedure TMainForm.XGridSetEditText(Sender: TObject; ACol, ARow: Integer; Const Value: String);
- Var
- I, J: Integer;
- Amount: Integer;
- Begin
- For I := 0 To XGrid.RowCount Do
- Begin
- For J := 0 To XGrid.ColCount Do
- Begin
- If ((Not TryStrToInt(XGrid.Cells[I, J], Amount)) And (XGrid.Cells[I, J] <> '') And (XGrid.Cells[I, J] <> '-')) Then
- Begin
- ShowMessage('Некорректные исходные данные!');
- XGrid.Cells[I, J] := '';
- End
- Else
- If (XGrid.Cells[I, J] <> '') And (XGrid.Cells[I, J] <> '-') Then
- Begin
- If Not(CheckXArea(StrToInt(XGrid.Cells[I, J]), MAX_X, MIN_X)) Then
- Begin
- ShowMessage('Некорректные исходные данные!');
- XGrid.Cells[I, J] := '';
- End;
- End;
- End;
- End;
- End;
- { Procedure TMainForm.CalcResult(Sender: TObject);
- Var
- Count, I, J: Integer;
- IsCorrect: Boolean;
- Begin
- Count := 0;
- IsCorrect := True;
- For J := 0 To StrToInt(MEdit.Text) - 1 Do
- Begin
- For I := 0 To StrToInt(NEdit.Text) - 2 Do
- Begin
- If (StrToFloat(XGrid.Cells[I, J]) >= (StrToFloat(XGrid.Cells[I+1, J]))) Then
- Begin
- IsCorrect := False;
- End;
- End;
- If IsCorrect Then
- Inc(Count);
- IsCorrect := True;
- End;
- ResultEdit.Text:='Количество отсортированных по возрастанию строк матрицы: '+IntToStr(Count);
- End; }
- procedure ShowProcess(Arr: TArr; StepProc: Integer; ResultMemo: TMemo);
- var
- I, J, K: Integer;
- TextToAdd: string;
- begin
- ResultMemo.Lines.Add('Шаг ' + IntToStr(StepProc) + ':');
- for I := 0 to High(Arr) do
- begin
- for J := 0 to High(Arr[I]) do
- begin
- TextToAdd := '';
- for K := 0 to High(Arr[I][J]) do
- TextToAdd := TextToAdd + IntToStr(Arr[I][J][K]) + ' ';
- ResultMemo.Lines.Add(TextToAdd);
- end;
- ResultMemo.Lines.Add('');
- end;
- end;
- procedure TMainForm.CalcResult(Sender: TObject);
- var
- Arr: TArr;
- Step: Real;
- I, IStep, Temp, AbsLength, X1, Y1, Z1, X2, Y2, Z2, CoefX, CoefY, StepProc: Integer;
- begin
- // Ваш код для инициализации массива Arr
- arr := EnterArr();
- AbsLength := Length(Arr) * Length(Arr[0]) * Length(Arr[0][0]);
- CoefX := Length(Arr[0]) * Length(Arr[0][0]);
- CoefY := Length(Arr[0][0]);
- Step := AbsLength - 1;
- StepProc := 1;
- while Step >= 1 do
- begin
- IStep := Trunc(Step);
- I := 0;
- while Step + I < AbsLength do
- begin
- X1 := I div CoefX;
- Y1 := (I - X1 * CoefX) div CoefY;
- Z1 := I - X1 * CoefX - Y1 * CoefY;
- X2 := (I + IStep) div CoefX;
- Y2 := (I + IStep - X2 * CoefX) div CoefY;
- Z2 := I + IStep - X2 * CoefX - Y2 * CoefY;
- if Arr[X1][Y1][Z1] > Arr[X2][Y2][Z2] then
- begin
- Temp := Arr[X1][Y1][Z1];
- Arr[X1][Y1][Z1] := Arr[X2][Y2][Z2];
- Arr[X2][Y2][Z2] := Temp;
- ShowProcess(Arr, StepProc, ResultMemo);
- Inc(StepProc);
- end;
- Inc(I);
- end;
- Step := Step / FACTOR;
- end;
- end;
- Procedure TMainForm.GridCheck(Sender: TObject);
- Var
- I, J: Integer;
- Amount: Extended;
- IsExistCell: Boolean;
- Begin
- XGrid.ColCount := strtoint(nedit.text)*strtoint(kedit.text);
- IsExistCell := True;
- For I := 0 To (XGrid.RowCount) - 1 Do
- Begin
- For J := 0 To XGrid.ColCount - 1 Do
- Begin
- If (XGrid.Cells[J, I] = '-') Then
- Begin
- IsExistCell := False;
- XGrid.Cells[J, I] := ''
- End;
- End;
- End;
- If Not(IsExistCell) Then
- ShowMessage('Некорректные исходные данные!');
- End;
- Procedure TMainForm.ResultButtonClick(Sender: TObject);
- Begin
- GridCheck(Sender);
- If CheckInputFields(Sender, NEdit, XGrid) Then
- CalcResult(Sender);
- End;
- Var
- IsSave: Boolean = False;
- Procedure TMainForm.SaveMenuClick(Sender: TObject);
- Var
- FilePath: String;
- F: TextFile;
- Begin
- If (ResultMemo.Text <> '') Then
- Begin
- If MySaveTextFileDialog.Execute Then
- Begin
- FilePath := MySaveTextFileDialog.FileName;
- AssignFile(F, FilePath);
- If FileIsReadOnly(FilePath) Then
- Application.MessageBox(PChar(ERRORS[EcNot_Writeable]), 'Ошибка', MB_OK + MB_ICONERROR)
- Else
- Begin
- Rewrite(F);
- Write(F, ResultMemo.Text);
- CloseFile(F);
- IsSave := True;
- End;
- End;
- End;
- End;
- Procedure TMainForm.FileMenuClick(Sender: TObject);
- Begin
- If ResultMemo.Text <> '' Then
- SaveMenu.Enabled := True
- Else
- SaveMenu.Enabled := False;
- End;
- Procedure TMainForm.FormCloseQuery(Sender: TObject; Var CanClose: Boolean);
- Var
- IsExit: Word;
- Begin
- If Not IsSave And (ResultMemo.Text <> '') Then
- Begin
- IsExit := Application.MessageBox('Вы не сохранили файл, хотите ли сохранить?', 'Выход', MB_YESNOCANCEL + MB_ICONQUESTION);
- Case IsExit Of
- MrYes:
- Begin
- CanClose := False;
- FileMenu.Click;
- SaveMenu.Click;
- End;
- MrNo:
- CanClose := True;
- MrCancel:
- CanClose := False;
- End;
- End
- Else
- Begin
- IsExit := Application.MessageBox('Вы действительно хотите выйти?', 'Выход', MB_YESNO + MB_ICONQUESTION);
- Case IsExit Of
- MrYes:
- CanClose := True;
- MrNo:
- CanClose := False;
- End;
- End;
- End;
- Procedure TMainForm.FormCreate(Sender: TObject);
- Begin
- TaskLabel.Caption := 'Данная программа сортирует трехмерный массив по возрастанию.';;
- End;
- Function TMainForm.CheckCells(CurStringGrid: TStringGrid): Boolean;
- Var
- I, J: Integer;
- Begin
- Result := True;
- For I := 0 To CurStringGrid.RowCount - 1 Do
- Begin
- For J := 0 To CurStringGrid.ColCount - 1 Do
- Begin
- If CurStringGrid.Cells[J, I] = '' Then
- Begin
- Result := False;
- Exit; //Если найдена пустая ячейка, выходим из функции
- End;
- End;
- End;
- End;
- Procedure TMainForm.ExitMenuClick(Sender: TObject);
- Var
- IsExit: Word;
- Begin
- If Not IsSave And (ResultMemo.Text <> '') Then
- Begin
- IsExit := Application.MessageBox('Вы не сохранили файл, хотите ли сохранить?', 'Выход', MB_YESNOCANCEL + MB_ICONQUESTION);
- Case IsExit Of
- MrYes:
- SaveMenu.Click;
- MrNo:
- Close;
- End;
- End
- Else
- Begin
- IsExit := Application.MessageBox('Вы действительно хотите выйти?', 'Выход', MB_YESNO + MB_ICONQUESTION);
- Case IsExit Of
- MrYes:
- Close;
- End;
- End;
- End;
- End.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement