Board index » delphi » Name of instance vs. name of class

Name of instance vs. name of class

Okay, another really newbie question here.

I create a form (using the IDE).  I name it "lengthInfo".  If I then invoke
the method

   lengthInfo.hide;

it has no effect.  Apparently the name I assign in the IDE is the name of
a new class, a descendant of TForm.  Is that correct?

If so, then I'd have to name each instance of the class that I create,
manually?  By using a statement of the form

   self.name := 'lengthInfo1';

?

I'm nervous about doing so because the Delphi (1) help system says not to
rename components at run time.  But do they mean CLASSES of components, or
individual instances?

Anyway, if

   lengthinfo.hide;

is wrong, why does it seemingly execute but do nothing?

(And why is the create code being called twice when I only create one form?)

In any case:  is there a way to create a form but not show it?  That is,
to create it with its visible property set to false?

Thanks.
--
Carl Fink      carl_f...@pall.com

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum

 

Re:Name of instance vs. name of class


Hi there,

Delphi make a class for you: TLengthInfo = class(TForm)... there is one
global variable in the unit LengthInfo: TLengthInfo with which you can do
your stuff if the form is created. If you auto-create the form, one instance
is created and assigned to that pointer...

If you create your own instances of the form, you have to keep track of
those forms with variables. If you use LengthInfo.Hide you're hiding the
(auto-)created form that is assigned to that variable... If you can't see
the form, it's probably hidden (visible = false)...

Try the project options and remove all auto-created forms (except for the
mainform) and try again:

LengthInfo := TLengthInfo.Create(Self);
LengthInfo.Show;

bla
bla

LengthInfo.Hide;

good luck!

--
Martijn Tonies
http://surf.to/seal97

<none of the text written above has got anything to do with Euro Partners
Informatici BV>

System Development
Euro Partners Informatici BV
http://www.euro-partners.nl

ca...@my-dejanews.com heeft geschreven in bericht
<6phu11$9t...@nnrp1.dejanews.com>...

Quote
>Okay, another really newbie question here.

>I create a form (using the IDE).  I name it "lengthInfo".  If I then invoke
>the method

>   lengthInfo.hide;

>it has no effect.  Apparently the name I assign in the IDE is the name of
>a new class, a descendant of TForm.  Is that correct?

>If so, then I'd have to name each instance of the class that I create,
>manually?  By using a statement of the form

>   self.name := 'lengthInfo1';

>?

>I'm nervous about doing so because the Delphi (1) help system says not to
>rename components at run time.  But do they mean CLASSES of components, or
>individual instances?

>Anyway, if

>   lengthinfo.hide;

>is wrong, why does it seemingly execute but do nothing?

>(And why is the create code being called twice when I only create one
form?)

>In any case:  is there a way to create a form but not show it?  That is,
>to create it with its visible property set to false?

>Thanks.
>--
>Carl Fink      carl_f...@pall.com

>-----== Posted via Deja News, The Leader in Internet Discussion ==-----
>http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum

Re:Name of instance vs. name of class


Totally agree with Martijn - not sure I like the way the auto-created form
variable is the same as the class name (without the 'T' suffix) - I've found
you've got to watch this...

The best solution I've found is to comment out or remove the autocreated for
variable, e.g.

{  var}
{      Form1: TForm1;}

... thus any freferences you made to the 'Form1' variable will no longer
compile (obvious reminder).

I generally only have the main form of the appliation auto-create anyway, as
this removes some of the maintenance stress :-)

Mike.

Other Threads