Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit MainUnit;
- interface
- uses
- Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
- Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.Menus, Vcl.StdCtrls,
- Vcl.Samples.Spin;
- type
- TMain = class(TForm)
- MainMenu: TMainMenu;
- InstructionMenu: TMenuItem;
- DeveloperMenu: TMenuItem;
- SizeSpinEdit: TSpinEdit;
- Label1: TLabel;
- BuildButton: TButton;
- procedure DeveloperMenuClick(Sender: TObject);
- procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
- procedure InstructionMenuClick(Sender: TObject);
- procedure SizeSpinEditChange(Sender: TObject);
- procedure SizeSpinEditKeyPress(Sender: TObject; var Key: Char);
- procedure BuildButtonClick(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- Main: TMain;
- Size: integer;
- implementation
- {$R *.dfm}
- Uses
- MagicBoxUnit, ShowSquareUnit;
- procedure TMain.BuildButtonClick(Sender: TObject);
- var
- Sum, Size: integer;
- begin
- if (SizeSpinEdit.Text = '') then
- MessageDlg('Введите порядок квадрата.', mtError, [mbOk], 0)
- else if (strToInt(SizeSpinEdit.Text) > 24) or (strToInt(SizeSpinEdit.Text) < 4) then
- MessageDlg('Порядок должен быть в диапазон 4..24.', mtError, [mbOk], 0)
- else if ((strToInt(SizeSpinEdit.Text) mod 4) <> 0) then
- MessageDlg('Порядок должен быть кратным 4.', mtError, [mbOk], 0)
- else
- begin
- ShowForm.Show;
- end;
- end;
- procedure TMain.DeveloperMenuClick(Sender: TObject);
- begin
- Application.MessageBox('Студент группы 151002 Раводин Александр.', 'О разработчике');
- end;
- procedure TMain.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
- var
- lpCaption, lpText: PChar;
- Tip: Integer;
- WND: HWND;
- begin
- WND := Main.Handle;
- lpCaption := 'Выход';
- lpText := 'Вы уверены, что хотите выйти?';
- Tip := MB_YESNO + MB_ICONINFORMATION + MB_DEFBUTTON2;
- case MessageBox(WND, lpText, lpCaption, Tip) of
- IDYES : CanClose := True;
- IDNO : CanClose := False;
- end;
- end;
- procedure TMain.InstructionMenuClick(Sender: TObject);
- Var
- InstructionMenu: TForm;
- Instruction: string;
- begin
- Instruction := 'Данная программа строит магический квадрат чётно-чётного порядка латинским способом.';
- InstructionMenu := CreateMessageDialog(Instruction, mtInformation, [mbOk], mbOK);
- InstructionMenu.ShowModal;
- InstructionMenu.Free;
- end;
- procedure TMain.SizeSpinEditChange(Sender: TObject);
- begin
- if SizeSpinEdit.Text <> '' then
- BuildButton.Enabled := true
- else
- BuildButton.Enabled := false;
- end;
- procedure TMain.SizeSpinEditKeyPress(Sender: TObject; var Key: Char);
- begin
- if (SizeSpinEdit.Value <> 0) and (Key = #13) then
- BuildButtonClick(Sender);
- if (SizeSpinEdit.Text = '0') and (Key <> #08) then
- Key := #0;
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement