Next, I want to make a class in which I pass Form, LayoutContainer
or Form, LayoutContainer
and MultiView
per parameter and within that class have the form open method with both types of parameters. / p>
type
TFormComp = class
public
class procedure AbrirForm(AFormClass: TComponentClass; LayoutContainer: TLayout); overload;
class procedure AbrirForm(AFormClass: TComponentClass; LayoutContainer: TLayout; mvMainMenu: TMultiView); overload;
end;
Procedure 1:
class procedure TFormComp.AbrirForm(AFormClass: TComponentClass; LayoutContainer: TLayout);
var
layoutClient, botaoMainMenu: TComponent;
fActiveForm : TForm;
begin
Application.CreateForm(AFormClass, FActiveForm);
//encontra o LayoutBase no form a ser exibido para adicionar ao frmPrincipal
layoutClient := fActiveForm.FindComponent('LayoutClient');
//if Assigned(layoutClient) then
LayoutContainer.AddObject(TLayout(layoutClient));
end;
Procedure 2:
class procedure TFormComp.AbrirForm(AFormClass: TComponentClass; LayoutContainer: TLayout;
mvMainMenu: TMultiView);
var
layoutClient, botaoMainMenu: TComponent;
fActiveForm : TForm;
begin
try
AbrirForm(ComponentClass, Layout);
// Encontra o botão de controle de Menu no form a ser exibido para
// associálo ao multiview do formPrincipal
botaoMainMenu := FActiveForm.FindComponent('buttMainMenu');
// if Assigned(botaoMainMenu) then
// Associa o BotaMainMenu ao MasterButton botão que inibe o MultiView
mvMainMenu.MasterButton := TControl(botaoMainMenu);
except on E: Exception do
end;
end;
The purpose of the class is to place a form inside a layout of another form.
- How can I resolve this by giving you two options?
- Is there a better way to do this?