R
Robert Meek
I recently began working with NET via VS 2005 and the Chrome Object
Pascal IDE add-on as I have no experiance with other languages. But i am
picking up C# as I go along...a consequence of having to read C# code in the
books I'm learning from.
I'm used to creating and then freeing and making nil all my secondary
forms as they are needed and no longer required because it saves on
resources thru the application session, and though I have no problem
creating an instance of my secondary form type and displaying it from the
NET project's MainForm, I would also like to be able to check if that
particular instance is in memory or not from some other secondary form and
if so just show it and bring it to the front of the screen, or if not,
create an instance of it.
One nice thing about Chrome is that it does allow you to use Globals if
you like, but I'm not sure if my definition of Globals is the same as NET's,
but in any case what I've been doing is adding a var of the secondary Form
type in the public section of my mainform's class definition. And then
create a new method also in the MainForm's public section which checks to
see if my form instance is nil or not and creates and/or shows it as
required. This method is then called by a button or menu item on the
mainform whose event is in the MainForm's Private section.
This part works just fine, and I can close the form and make sure it is
released by having button event on the secondary form instance itself which
calls the form's Dispose method. But if I have the required MainForm in
which the second Form's instance variable is declared in I cannot create
that instance or even do anything with it from an event on a third form! It
tells me I have to create a new instance in order to do so. But that leaves
me in a position where the user could possibly create multiple instances of
the same Form type and I don't wish to allow that. I just want to to allow
the user to create one instance of the Form type, but from any other Form in
the project. And if the Form instance is already created, then I just want
the user to be able to bring that instance to the front of the screen from
any other Form!
I realize I took a long time to state a simple problem but as this is
new to me I wanted to be sure I was understood. Any help would be
appreaciated!
Pascal IDE add-on as I have no experiance with other languages. But i am
picking up C# as I go along...a consequence of having to read C# code in the
books I'm learning from.
I'm used to creating and then freeing and making nil all my secondary
forms as they are needed and no longer required because it saves on
resources thru the application session, and though I have no problem
creating an instance of my secondary form type and displaying it from the
NET project's MainForm, I would also like to be able to check if that
particular instance is in memory or not from some other secondary form and
if so just show it and bring it to the front of the screen, or if not,
create an instance of it.
One nice thing about Chrome is that it does allow you to use Globals if
you like, but I'm not sure if my definition of Globals is the same as NET's,
but in any case what I've been doing is adding a var of the secondary Form
type in the public section of my mainform's class definition. And then
create a new method also in the MainForm's public section which checks to
see if my form instance is nil or not and creates and/or shows it as
required. This method is then called by a button or menu item on the
mainform whose event is in the MainForm's Private section.
This part works just fine, and I can close the form and make sure it is
released by having button event on the secondary form instance itself which
calls the form's Dispose method. But if I have the required MainForm in
which the second Form's instance variable is declared in I cannot create
that instance or even do anything with it from an event on a third form! It
tells me I have to create a new instance in order to do so. But that leaves
me in a position where the user could possibly create multiple instances of
the same Form type and I don't wish to allow that. I just want to to allow
the user to create one instance of the Form type, but from any other Form in
the project. And if the Form instance is already created, then I just want
the user to be able to bring that instance to the front of the screen from
any other Form!
I realize I took a long time to state a simple problem but as this is
new to me I wanted to be sure I was understood. Any help would be
appreaciated!