1
Following guys, I’m looking to make a class in which I pass the Form, LayoutContainer
or Form, LayoutContainer
and MultiView
by parameter and within this class have the method open form with the two types of parameters.
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 solve this way by providing two options?
- There’s a better way to do that?