Code: Select all
const
ciFormWidth = 300;
ciFormHeight = 200;
var
ParametersForm: TForm;
function CreateButton(aParent: TWinControl; const aCaption: string; aLeft, aTop, aWidth, aHeight, aModalResult: Integer): TButton;
begin
Result := TButton.Create(ParametersForm);
Result.SetBounds(aLeft, aTop, aWidth, aHeight);
Result.Caption := aCaption;
Result.ModalResult := aModalResult;
Result.Parent := aParent
end;
function CreateGroupBox(aParent: TWinControl; const aCaption: string; aLeft, aTop, aWidth, aHeight: Integer): TGroupBox;
begin
Result := TGroupBox.Create(ParametersForm);
Result.SetBounds(aLeft, aTop, aWidth, aHeight);
Result.Caption := aCaption;
Result.Parent := aParent
end;
function CreateCheckBox(aParent: TWinControl; const aCaption: string; aLeft, aTop, aWidth, aHeight: Integer): TCheckBox;
begin
Result := TCheckBox.Create(ParametersForm);
Result.SetBounds(aLeft, aTop, aWidth, aHeight);
Result.Caption := aCaption;
Result.Parent := aParent
end;
procedure CreateCheckBoxes(aParent: TWinControl; const aCaptions: array of string; var aCheckBoxes: array of TCheckBox);
var
i, iLeft, iTop: Integer;
begin
SetLength(aCheckBoxes, Length(aCaptions));
iLeft := 10; iTop := 20;
for i := 0 to Length(aCaptions) - 1 do begin
aCheckBoxes[i] := CreateCheckBox(aParent, aCaptions[i], iLeft, iTop, aParent.Width - 20, 20);
iTop := iTop + 25
end
end;
var
i: Integer;
ParametersCheckBoxes: array of TCheckBox;
ParametersGroupBox: TGroupBox;
begin
ParametersForm := TForm.Create(Application);
try
ParametersForm.ClientWidth := ciFormWidth;
ParametersForm.ClientHeight := ciFormHeight;
ParametersForm.Caption := 'Создание подкаст-лент';
ParametersForm.Position := poScreenCenter;
ParametersGroupBox := CreateGroupBox(ParametersForm, 'Параметры', 10, 10, ciFormWidth - 20, ciFormHeight - 55);
CreateButton(ParametersForm, 'OK', ciFormWidth - 170, ciFormHeight - 35, 75, 25, mrOK);
CreateButton(ParametersForm, 'Отмена', ciFormWidth - 85, ciFormHeight - 35, 75, 25, mrCancel);;
CreateCheckBoxes(ParametersGroupBox, ['Параметр 1', 'Параметр 2', 'Параметр 3', 'Параметр 4', 'Параметр 5'], ParametersCheckBoxes);
if ParametersForm.ShowModal = mrOK then begin
for i := 0 to Length(ParametersCheckBoxes) - 1 do
if ParametersCheckBoxes[i].Checked then
ShowMessage('Параметр ' + IntToStr(i + 1) + ' включен')
end
finally
ParametersForm.Free
end
end.