Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit Unit2F;
- interface
- uses
- Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
- System.Classes, Vcl.Graphics,
- Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.Menus;
- type
- TLab1_1 = class(TForm)
- Button1: TButton;
- MainMenu: TMainMenu;
- N1: TMenuItem;
- MenuItemAboutProgram: TMenuItem;
- N3: TMenuItem;
- PopupMenu: TPopupMenu;
- EditRadius: TEdit;
- EditY: TEdit;
- EditX: TEdit;
- Result: TLabel;
- Label1: TLabel;
- Label2: TLabel;
- Label3: TLabel;
- procedure MenuItemAboutProgramClick(Sender: TObject);
- procedure EditRadiusKeyPress(Sender: TObject; var Key: Char);
- procedure EditKeyDown(Sender: TObject; var Key: Word;
- Shift: TShiftState);
- procedure Button1Click(Sender: TObject);
- procedure N3Click(Sender: TObject);
- procedure OnCloseQuery(Sender: TObject; var CanClose: Boolean);
- procedure EditChange(Sender: TObject);
- procedure EditXKeyPress(Sender: TObject; var Key: Char);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- Lab1_1: TLab1_1;
- implementation
- {$R *.dfm}
- procedure TLab1_1.EditChange(Sender: TObject); // проверка на пустотут всех трех
- const
- TypeError = 'Попытка ввода нечислового типа данных.';
- var
- WrostInput: Boolean;
- begin
- Button1.Enabled := True;
- with Sender as TEdit do
- begin
- WrostInput := False;
- try
- if (Length(EditRadius.Text) = 0) then
- Button1.Enabled := False;
- if (Length(EditRadius.Text) > 0) and (EditRadius.Text[1] = '-') then //todo
- if (EditRadius.Text[2] = '0') then
- begin
- Clear;
- Button1.Enabled := False;
- end;
- if (Length(EditX.Text) = 0) then
- Button1.Enabled := False;
- if (Length(EditX.Text) = 1) and (EditX.Text[1] = '-') then
- Button1.Enabled := False;
- if (Length(EditX.Text) > 0) and (EditX.Text[1] = '-') then
- if (EditX.Text[2] = '0') then
- begin
- Clear;
- Button1.Enabled := False;
- end;
- if (Length(EditY.Text) = 0) then
- Button1.Enabled := False;
- if (Length(EditY.Text) = 1) and (EditY.Text[1] = '-') then
- Button1.Enabled := False;
- if (Length(EditY.Text) > 0) and (EditY.Text[1] = '-') then
- if (EditY.Text[2] = '0') then
- begin
- Clear;
- Button1.Enabled := False;
- end;
- except
- MessageDlg(TypeError, mtError, [mbOk], 0);
- WrostInput := True;
- end;
- if WrostInput then
- begin
- Text := '';
- Button1.Enabled := False
- end;
- end;
- end;
- procedure TLab1_1.Button1Click(Sender: TObject);
- const
- Eps = 0.001;
- Mess = 'Поле должно быть заполненно.';
- var
- X, Y, Radius: Integer;
- HypotenuseSqr: Double;
- IsLiesOnTheCircle: Boolean;
- begin
- Radius := StrToInt(EditRadius.Text);
- X := StrToInt(EditX.Text);
- Y := StrToInt(EditY.Text);
- HypotenuseSqr := sqrt(X * X + Y * Y);
- if Abs(HypotenuseSqr - Radius) < Eps then
- Result.Caption := 'Точка с заданными координатами' + #13#10 +
- 'лежит на окружности.'
- else
- Result.Caption := 'Точка с заданными координатами' + #13#10 +
- 'не лежит на окружности.';
- Result.Visible := True;
- end;
- procedure TLab1_1.EditKeyDown(Sender: TObject; var Key: Word;
- Shift: TShiftState);
- var
- CurrentEdit: TEdit;
- begin
- CurrentEdit := TEdit(Sender);
- if (ssShift in Shift) then
- Key := 0;
- if ((CurrentEdit.SelStart <> Length(CurrentEdit.Text)) and
- ((Key = 46) or (Key = 8))) then
- Key := 0;
- end;
- procedure TLab1_1.EditXKeyPress(Sender: TObject; var Key: Char);
- var
- Numerals: set of Char;
- begin
- with Sender as TEdit do
- begin
- if (Key = #13) and (Button1.Enabled) then
- Button1Click(Sender);
- if Length(Text) = 0 then
- Numerals := ['-', '0' .. '9', #8, #31]
- else
- Numerals := ['0' .. '9', #8, #31];
- if not(Key in Numerals) then
- Key := #0;
- if (Length(Text) > 0) and (Text[1] = '0') and (Key <> #8) then
- Key := #0;
- if (Key = #8) and (Length(Text) = 2) and (Text[1] = '-') then
- Text := '';
- if (Length(Text) > 0) and (Text[1] = '-') then
- begin
- if (Length(Text) = 3) and (Key <> #8) then
- Key := #0;
- end
- else
- begin
- if (Length(Text) = 2) and (Key <> #8) then
- Key := #0;
- end;
- end;
- end;
- procedure TLab1_1.EditRadiusKeyPress(Sender: TObject; var Key: Char);
- var
- Numerals: set of Char;
- begin
- Numerals := ['0' .. '9', #8];
- with Sender as TEdit do
- begin
- if (Key = #13) and (Button1.Enabled) then
- Button1Click(Sender);
- if not(Key in Numerals) then
- Key := #0;
- if (Length(Text) = 2) and (Key <> #8) then
- Key := #0;
- if (Length(Text) = 0) and (Key = '0') then
- Key := #0;
- end;
- end;
- procedure TLab1_1.MenuItemAboutProgramClick(Sender: TObject);
- const
- ProgramTask =
- 'Данная программа определяет находиться ли точка* на окружности.' + #13#10
- + '* Диапазон значени для радиуса (0; 100).' + #13#10 +
- ' Для координат точки (-100; 100).';
- begin
- MessageDlg(ProgramTask, mtInformation, [mbOk], 0);
- end;
- procedure TLab1_1.N3Click(Sender: TObject);
- const
- Programer =
- 'Данная программа разработанa Семенцовой Критиной, студенткой 1 курса БГУИР, факультет КСИС, специальность ПОИТ.';
- begin
- MessageDlg(Programer, mtInformation, [mbOk], 0);
- end;
- procedure TLab1_1.OnCloseQuery(Sender: TObject; var CanClose: Boolean);
- const
- AreSure = 'Вы уверены, что хотите выйти?';
- var
- SelectedButton: Byte;
- begin
- SelectedButton := MessageDlg(AreSure, mtConfirmation, [mbYes, mbNo], 0);
- if SelectedButton <> mrYes then
- CanClose := False;
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement