This is what my project looks like:
I have 4 forms. The first form is the form containing some
procedures that all other forms use. This form is set as
the projects main form so I can close the others without the
application shutting down. Application.ShowMainForm is set
to false so users cannot accidentally close it. This is the
only autocreated form.
The second form is a splash screen. It contains two labels
a timer, a panel, and a image. This form only exists for
3 seconds max and then is freed by the next form. It also
creates the next form.
The third form has the first user interface. This is what my
users will mostly be using. It contains allot of components.
209 to be exact. It has a global variable called CloseForm
which is boolean. This variable is set to false when the
form is created and in the OnCloseQuery event it is set to
true. Also all the timers are disabled and freed in this
event. This variable is used to break all for and while
loops so that none of them are running while the
is closing. It is just a precaution. In the onClose event
about 20 settings for my application are written to a
IniFile and is also of course freed.
The forth form is like the first form, containing a user
interface and lots of components. 169. I cant have this form
and the previously mentioned form running at the same time
because together they contain to many components and cause
a massive drain on User and System memory.
Now what I have done is this. In the mainform, the one I
mentioned first, I have a procedure like this:
procedure FreeAndLoadAForm(FreeForm: Integer; LoadForm: Integer);
var MyRFormArray: array[1..3] of TForm;
var MyTFormArray: array[1..3] of TFormClass;
begin
MyRFormArray[1] := Form2;
MyRFormArray[2] := Form3;
MyRFormArray[3] := Form4;
MyTFormArray[1] := TForm2;
MyTFormArray[2] := TForm3;
MyTFormArray[3] := TForm4;
MyRFormArray[FreeForm].Free;
Application.CreateForm(MyTFormArray[LoadForm],MyRFormArray[LoadForm]);
end;
This procedure works well in other applications of mine but
in this one I keep getting EAccessViolations when I try to
close the third form. I have get it when I just use Self.Close
(or Free or Release for that matter) Do you know
what could be causing this ??? Everything goes fine until
it actually closes the form, it even does write the inifile
away properly and it also free's it properly. I dont know
what could be causing this. Do you guys have any idea's on
what I could look at to find the solution ???
Thanx allot, BobbaFet
Everyone has a right to my opinion.
E-mail me at caswegkamp@hotmail.com
I have 4 forms. The first form is the form containing some
procedures that all other forms use. This form is set as
the projects main form so I can close the others without the
application shutting down. Application.ShowMainForm is set
to false so users cannot accidentally close it. This is the
only autocreated form.
The second form is a splash screen. It contains two labels
a timer, a panel, and a image. This form only exists for
3 seconds max and then is freed by the next form. It also
creates the next form.
The third form has the first user interface. This is what my
users will mostly be using. It contains allot of components.
209 to be exact. It has a global variable called CloseForm
which is boolean. This variable is set to false when the
form is created and in the OnCloseQuery event it is set to
true. Also all the timers are disabled and freed in this
event. This variable is used to break all for and while
loops so that none of them are running while the
is closing. It is just a precaution. In the onClose event
about 20 settings for my application are written to a
IniFile and is also of course freed.
The forth form is like the first form, containing a user
interface and lots of components. 169. I cant have this form
and the previously mentioned form running at the same time
because together they contain to many components and cause
a massive drain on User and System memory.
Now what I have done is this. In the mainform, the one I
mentioned first, I have a procedure like this:
procedure FreeAndLoadAForm(FreeForm: Integer; LoadForm: Integer);
var MyRFormArray: array[1..3] of TForm;
var MyTFormArray: array[1..3] of TFormClass;
begin
MyRFormArray[1] := Form2;
MyRFormArray[2] := Form3;
MyRFormArray[3] := Form4;
MyTFormArray[1] := TForm2;
MyTFormArray[2] := TForm3;
MyTFormArray[3] := TForm4;
MyRFormArray[FreeForm].Free;
Application.CreateForm(MyTFormArray[LoadForm],MyRFormArray[LoadForm]);
end;
This procedure works well in other applications of mine but
in this one I keep getting EAccessViolations when I try to
close the third form. I have get it when I just use Self.Close
(or Free or Release for that matter) Do you know
what could be causing this ??? Everything goes fine until
it actually closes the form, it even does write the inifile
away properly and it also free's it properly. I dont know
what could be causing this. Do you guys have any idea's on
what I could look at to find the solution ???
Thanx allot, BobbaFet
Everyone has a right to my opinion.
E-mail me at caswegkamp@hotmail.com