1
I have 2 Forms in a Delphi application. When I open the system to register I open the two Forms, the main and the registration. The problem comes when I try to close the registration form because it closes the whole system and I do not know what to do... I will leave down the codes.
Register form layer.
procedure TfrmPrincipal.btnClienteClick(Sender: TObject); begin if frmCliente = nil then Application.CreateForm(TfrmCliente, frmCliente); frmCliente.Parent := frmPrincipal; frmCliente.Show; frmPrincipal.pnTelaPrincipal_Titulo1.Enabled := False; frmPrincipal.pnNavegacao.Enabled := False; frmPrincipal.pnBaseManutencao01.Enabled := False; end;
Form layer Close frmCliente.
procedure TfrmCliente.btnCloseClick(Sender: TObject); begin frmPrincipal.pnTelaPrincipal_Titulo1.Enabled := True; frmPrincipal.pnNavegacao.Enabled := True; frmPrincipal.pnBaseManutencao01.Enabled := True; frmCliente.Close; frmPrincipal.AtualizaBotoesAdicionais; end;
After Breackpoint goes through end;
of btnCloseClick
it goes to the Formclose of the frmPrincipal closed the whole system.
procedure TfrmPrincipal.FormClose(Sender: TObject; var Action: TCloseAction);
begin
DM.qryUsoGeral.Close;
DM.qryLocaliza.Close;
FreeAndNil(TfrmPrincipal);
end;
I want to know why that is and how to fix it.
On request I’ll leave the . dpr here
program Autosad;
{$R *.dres}
uses
Windows,
Vcl.Forms,
UHPI in 'FONTES\Classe\UHPI.pas',
UAcompanhamentoProcessos in 'FONTES\UAcompanhamentoProcessos.pas' {frmAcompanhamentoProcessos},
UAlterarSenha in 'FONTES\UAlterarSenha.pas' {frmAlterarSenha},
UAndamentoProcessual in 'FONTES\UAndamentoProcessual.pas' {frmAndamentoProcessual},
UAtualizacoesVersao in 'FONTES\UAtualizacoesVersao.pas' {frmAtualizacoesVersao},
UCentroCustos in 'FONTES\UCentroCustos.pas' {frmCentroCusto},
UClienteAdicionais in 'FONTES\UClienteAdicionais.pas' {frmClienteAdicionais},
UConsultas in 'FONTES\UConsultas.pas' {frmConsultas},
UDataModuleGeral in 'FONTES\UDataModuleGeral.pas' {DataModuleGeral: TDataModule},
UDataModuleGeral2 in 'FONTES\UDataModuleGeral2.pas' {DataModuleGeral2: TDataModule},
UDataModuleGeral3 in 'FONTES\UDataModuleGeral3.pas' {DataModuleGeral3: TDataModule},
UDataModuleRelatorios in 'FONTES\UDataModuleRelatorios.pas' {DataModuleRelatorios: TDataModule},
UEmprestimos in 'FONTES\UEmprestimos.pas' {frmEmprestimos},
UEntradaSistema in 'FONTES\UEntradaSistema.pas' {frmEntradaSistema},
UEnviaEmailClientes in 'FONTES\UEnviaEmailClientes.pas' {frmEnviaEmailClientes},
UFiltrosFluxoCaixa in 'FONTES\UFiltrosFluxoCaixa.pas' {frmFiltrosFluxoCaixa},
UFiltrosGraficos in 'FONTES\UFiltrosGraficos.pas' {frmFiltrosGraficos},
UFinanceiro in 'FONTES\UFinanceiro.pas' {frmFinanceiro},
UFluxoCaixa in 'FONTES\UFluxoCaixa.pas' {frmFluxoCaixa},
UGraficosEstatisticos in 'FONTES\UGraficosEstatisticos.pas' {frmGraficosEstatisticos},
UInfoCliente in 'FONTES\UInfoCliente.pas' {frmInfoCliente},
UManutencaoAdvogados in 'FONTES\UManutencaoAdvogados.pas' {frmManutencaoAdvogados},
UManutencaoAgenda in 'FONTES\UManutencaoAgenda.pas' {frmManutencaoAgenda},
UManutencaoAudiencias in 'FONTES\UManutencaoAudiencias.pas' {frmManutencaoAudiencias},
UManutencaoBiblioteca in 'FONTES\UManutencaoBiblioteca.pas' {frmManutencaoBiblioteca},
UManutencaoClientes in 'FONTES\UManutencaoClientes.pas' {frmManutencaoClientes},
UManutencaoContasPagar in 'FONTES\UManutencaoContasPagar.pas' {frmManutencaoContasPagar},
UManutencaoContatos in 'FONTES\UManutencaoContatos.pas' {frmManutencaoContatos},
UManutencaoContratos in 'FONTES\UManutencaoContratos.pas' {frmManutencaoContratos},
UManutencaoFornecedores in 'FONTES\UManutencaoFornecedores.pas' {frmManutencaoFornecedores},
UManutencaoHonorarios in 'FONTES\UManutencaoHonorarios.pas' {frmManutencaoHonorarios},
UManutencaoParametros in 'FONTES\UManutencaoParametros.pas' {frmManutencaoParametros},
UManutencaoProcessos in 'FONTES\UManutencaoProcessos.pas' {frmManutencaoProcessos}, // <== Estou Utilizando esses From para fazer os testes
UManutencaoUnidades in 'FONTES\UManutencaoUnidades.pas' {frmManutencaoUnidades},
UManutencaoUsuarios in 'FONTES\UManutencaoUsuarios.pas' {frmManutencaoUsuarios},
UMudancaGrupalProcessos in 'FONTES\UMudancaGrupalProcessos.pas' {frmMudancaGrupalProcessos},
UNovoCEP in 'FONTES\UNovoCEP.pas' {frmNovoCEP},
UNovoFornecedor in 'FONTES\UNovoFornecedor.pas' {frmNovoFornecedor},
UNovoModelo in 'FONTES\UNovoModelo.pas' {frmNovoModelo},
UParteContrariaAdicionais in 'FONTES\UParteContrariaAdicionais.pas' {frmParteContrariaAdicionais},
UPesquisaClientes in 'FONTES\UPesquisaClientes.pas' {frmPesquisaClientes},
UPesquisaContasPagar in 'FONTES\UPesquisaContasPagar.pas' {frmPesquisaContasPagar},
UPesquisaContatos in 'FONTES\UPesquisaContatos.pas' {frmPesquisaContatos},
UPesquisaContratos in 'FONTES\UPesquisaContratos.pas' {frmPesquisaContratos},
UPesquisaFornecedores in 'FONTES\UPesquisaFornecedores.pas' {frmPesquisaFornecedores},
UPesquisaHonorarios in 'FONTES\UPesquisaHonorarios.pas' {frmPesquisaHonorarios},
UPesquisaProcessos in 'FONTES\UPesquisaProcessos.pas' {frmPesquisaProcessos},
UPublicacoes in 'FONTES\UPublicacoes.pas' {frmPublicacoes},
USelecaoRelatoriosContasPagar in 'FONTES\USelecaoRelatoriosContasPagar.pas' {frmSelecaoRelatoriosContasPagar},
USelecaoRelatoriosHonorarios in 'FONTES\USelecaoRelatoriosHonorarios.pas' {frmSelecaoRelatoriosHonorarios},
USelecaoRelatoriosProcessos in 'FONTES\USelecaoRelatoriosProcessos.pas' {frmSelecaoRelatoriosProcessos},
USplash in 'FONTES\USplash.pas' {frmSplash},
UTelaPrincipal in 'FONTES\UTelaPrincipal.pas' {frmTelaPrincipal},
UUtilitarios in 'FONTES\UUtilitarios.pas' {frmUtilitarios},
UVisualizadorDeProcessos in 'FONTES\UVisualizadorDeProcessos.pas' {frmVisualizadorDeProcessos},
UNovasPublicacoes in 'FONTES\UNovasPublicacoes.pas' {frmNovasPublicacoes},
USobre in 'FONTES\USobre.pas' {frmSobre},
Vcl.Themes,
Vcl.Styles,
UFuncoes in 'Fontes\Classe\UFuncoes.pas';
{$R *.res}
{$SetPEFlags IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP}
{$DEFINE IMAGE_DLLCHARACTERISTICS_TERMINAL_SERVER_AWARE = $ 8000}
{$SetPEOptFlags IMAGE_DLLCHARACTERISTICS_TERMINAL_SERVER_AWARE}
{$SetPEFlags IMAGE_FILE_RELOCS_STRIPPED or IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP or IMAGE_FILE_NET_RUN_FROM_SWAP}
begin
{$IFDEF DEBUG}
ReportMemoryLeaksOnShutdown := True;
{$ENDIF}
Application.Initialize;
Application.MainFormOnTaskbar := True;
Application.Title := 'Autosad - Gerenciador de Processos Jurídicos';
Application.CreateForm(TDataModuleGeral, DataModuleGeral);
Application.CreateForm(TDataModuleGeral2, DataModuleGeral2);
Application.CreateForm(TfrmEntradaSistema, frmEntradaSistema);
Application.CreateForm(TDataModuleGeral3, DataModuleGeral3);
Application.CreateForm(TDataModuleRelatorios, DataModuleRelatorios);
Application.Run;
end.
Edu, enter your project code (dpr) here. Also check if events are linked to the correct procedures.
– Ricardo Alves Carvalho
In dpr the main form of the application is frmEntradaSystem. The two Forms that appear in your code are not being automatically created. From the code, you can see that you are coding actions of one form into another. That’s not very good. It creates a tangle that makes maintenance very difficult, especially when the project evolves. Possibly you are making an incorrect call, but it is not appearing in the code you posted. Things that may be happening:
– Ricardo Alves Carvalho
The secondary form is the main application form (first Application.Createform); in the Object inspector one Handler may be assigned to the wrong event, from another form; a form that should be child is the other’s Owner.
– Ricardo Alves Carvalho