Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > FireMonkey
Registrarse FAQ Miembros Calendario Guía de estilo Buscar Temas de Hoy Marcar Foros Como Leídos

 
 
Herramientas Buscar en Tema Desplegado
  #9  
Antiguo 26-03-2023
Avatar de duilioisola
[duilioisola] duilioisola is offline
Miembro Premium
 
Registrado: ago 2007
Ubicación: Barcelona, España
Posts: 1.744
Poder: 20
duilioisola Es un diamante en brutoduilioisola Es un diamante en brutoduilioisola Es un diamante en bruto
Cita:
... estoy intentando de todo para abrir y cerrar los formulario pero me da error. cual es la sentencia correcta para abrir y cerra un formulario que no esta en autocreate?
Básicamente tienes que ejecutar la sentencias
Código Delphi [-]
Formulario := TFormulario.Create(Self);
Transcribo a continuación la ayuda de Delphi 6.

Creating forms dynamically
You may not always want all your application’s forms in memory at once. To reduce the amount of memory required at load time, you may want to create some forms only when you need to use them. For example, a dialog box needs to be in memory only during the time a user interacts with it.
To create a form at a different stage during execution using the IDE, you:
  1. Select the File|New Form from the main menu to display the new form.
  2. Remove the form from the Auto-create forms list of the Project|Options|Forms page.
    This removes the form’s invocation. As an alternative, you can manually remove the following line from program’s main entry point:
    Application.CreateForm(TResultsForm, ResultsForm);
  3. Invoke the form when desired by using the form’s Show method, if the form is modeless, or ShowModal method, if the form is modal.
An event handler for the main form must create an instance of the result form and destroy it. One way to invoke the result form is to use the global variable as follows. Note that ResultsForm is a modal form so the handler uses the ShowModal method.

Código Delphi [-]
procedure TMainForm.Button1Click(Sender: TObject);
begin
ResultsForm:=TResultForm.Create(self);
try
  ResultsForm.ShowModal;
finally
  ResultsForm.Free;
end;
In the above example, note the use of try..finally. Putting in the line ResultsForm.Free; in the finally clause ensures that the memory for the form is freed even if the form raises an exception.
The event handler in the example deletes the form after it is closed, so the form would need to be recreated if you needed to use ResultsForm elsewhere in the application. If the form were displayed using Show you could not delete the form within the event handler because Show returns while the form is still open.

Note: If you create a form using its constructor, be sure to check that the form is not in the Auto-create forms list on the Project Options|Forms page. Specifically, if you create the new form without deleting the form of the same name from the list, Delphi creates the form at startup and this event-handler creates a new instance of the form, overwriting the reference to the auto-created instance. The auto-created instance still exists, but the application can no longer access it. After the event-handler terminates, the global variable no longer points to a valid form. Any attempt to use the global variable will likely crash the application.


En el caso de que quieras mostrar un formulario con ShowModal puedes envolver todo en un try..finally
En el caso de mostrarlo con Show no debes hacerlo porque estarías eliminándolo inmediatamente después de crearlo.
En ese caso debes crearlo y dejar que el formulario en su evento OnClose establezca la acción caFree;

Código Delphi [-]
procedure TFormulario.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  inherited;
  Action := caFree;
end;
Responder Con Cita
 


Herramientas Buscar en Tema
Buscar en Tema:

Búsqueda Avanzada
Desplegado

Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Cual es la mejor opción de conexión a Bases de Datos en Lazarus para ... ? rolandoj Lazarus, FreePascal, Kylix, etc. 20 24-09-2012 01:44:57
Cual es el mejor manejador gratis de base de datos para MySQl 5.0+ ? juangabriel1786 SQL 3 15-12-2008 00:10:29
Cual es la mejor opcion para un sistema de esta clase... jcarteagaf Varios 10 24-09-2008 23:57:51
Sobre cuál es la mejor opción para trabajar con Word Gabo Servers 6 16-01-2008 13:36:21
Cual es la mejor opción para imprimir ?? Delphitest Impresión 4 27-10-2006 21:50:59


La franja horaria es GMT +2. Ahora son las 18:48:35.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi