PDA

Ver la Versión Completa : formulario con error


Patricio
21-09-2007, 21:23:19
Hola gente, tengo el siguiente problema, me aparece el error ...

access violation at address.... in Module......at adress....

el tema es que tengo un formulario, que me permite mostrar un cliente y tambien agregar un cliente........y cuando estoy agregando un cliente es posible que tambien agregue personas relacionadas, para lo cual utilizo el mismo formulario. Es decir q desde 1 formulario se llamaria al mismo formulario....

Ahora lo estoy haciendo asi: cuando quiero llamar al formulario que se puede abrir varias veces hago lo siguiente:

FNuevoNombre:TFUFormularioComun;
begin
FNuevoNombre := TFFormularioComun.create(...);
....
FNuevoNombre.showmodal;
FNuevoNombre.release;

el tema es que en algun momento aleatoriamente me tira el error antes mencionado....estoy haciendo algo mal?
Gracias y espero se entienda

maeyanes
21-09-2007, 21:31:15
Hola...

Prueba con algo como esto:


FNuevoNombre := TFFormularioComun.Create(nil);
try
FNuevoNombre.ShowModal
finally
FNuevoNombre.Free
end


Tambien podrías usar la siguiente forma:


with TFormularioComun.Create(nil) do
try
ShowModal
finally
Free
end


Saludos...

Patricio
22-09-2007, 15:59:34
gracias x responder maeyanes, voy a probarlo y te aviso

Patricio
24-09-2007, 20:28:17
Ya q estamos les quisiera preguntar que diferencia hay entre free y release

maeyanes
24-09-2007, 20:37:14
Hola...

Haciendo una búsqueda en Google...


Release is intended to be used from a method of the form itself. It delays the actual
destruction of the form by posting a message to the message queue. This allows code
executed inside the form methods to still access any form members. The form will
get destroyed once the code flow returns to the message loop and the message is
delivered to the form.

Free directly calls the forms destructor, so after the statement returns the form
object is no more. Use Free to destroy a form from outside, Release from inside.



Saludos...

dec
24-09-2007, 20:42:03
Hola,

Aquí un artículo de Ian Marteens sobre el método Release() (http://www.marteens.com/answ02.htm). :)

Patricio
24-09-2007, 20:59:09
los voy a mirar gracias x responder