Board index » delphi » Help-non-visual components without forms OR how to hide your main form

Help-non-visual components without forms OR how to hide your main form

I am working on a project where a simple app must be always running in
Windows to check a condition every minute or so. I would like the program to
be hidden to the user so they can't easily terminate it and it is out of
their way. I know if I edit the project source I can remove the form unit and
the references to Application inorder to make my program formless, but I
wanted to use the TTimer component in my app and I cannot figure out how to
create an object at runtime without a form to pass as the parent. The help
files suggest that 'Self' be used as the parent (Timer :=
TTimer.Create(Self)), but I get an error saying that it doesn't know what
self is and the docs don't give a reference to a unit that defines Self.

Once I gave up on going formless I tried to make a form and hide it in the
form's OnCreate Event, but this doesn't work. I don't know why, I don't get
an error, it just doesn't work. But I know this form can be hiden because if
I put a button on this form and have the button's OnClick Event Hide the form
everything works fine.

So can anyone tell me how to do 1 of these
1. Create a TTimer without a form.
2. Hide my main form for the whole program execution.
3. Replace TTimer (without hogging resources), maybe with a API call?

Thanks for your time

William Holtz

 

Re:Help-non-visual components without forms OR how to hide your main form


Quote
bad...@crow.delta-eng.com (William Holtz) wrote:
>I am working on a project where a simple app must be always running in
>Windows to check a condition every minute or so. I would like the program to
>be hidden to the user so they can't easily terminate it and it is out of
>their way. I know if I edit the project source I can remove the form unit and
>the references to Application inorder to make my program formless, but I
>wanted to use the TTimer component in my app and I cannot figure out how to
>create an object at runtime without a form to pass as the parent. The help
>files suggest that 'Self' be used as the parent (Timer :=
>TTimer.Create(Self)), but I get an error saying that it doesn't know what
>self is and the docs don't give a reference to a unit that defines Self.
>Once I gave up on going formless I tried to make a form and hide it in the
>form's OnCreate Event, but this doesn't work. I don't know why, I don't get
>an error, it just doesn't work. But I know this form can be hiden because if
>I put a button on this form and have the button's OnClick Event Hide the form
>everything works fine.
>So can anyone tell me how to do 1 of these
>1. Create a TTimer without a form.
>2. Hide my main form for the whole program execution.

  don't declare a main form-- undeclare the main form if your project
  started out with one.  Design a form with a timer on it as non-auto-
  create.  In your dpr file, create the form by hand, with the
  visible:= false property.  Create it with the timer disabled.
  When you are done with your setup, enable the timer.  The form does
  not need to be visible to do so.

Quote
>3. Replace TTimer (without hogging resources), maybe with a API call?
>Thanks for your time

 any time

 Tom

- Show quoted text -

Quote
>William Holtz

Re:Help-non-visual components without forms OR how to hide your main form


Quote
ridge...@u.washington.edu (Thomas Ridgeway) wrote:
>bad...@crow.delta-eng.com (William Holtz) wrote:

>>I am working on a project where a simple app must be always running in
>>Windows to check a condition every minute or so. I would like the program to
>>be hidden to the user so they can't easily terminate it and it is out of
>>their way. I know if I edit the project source I can remove the form unit and
>>the references to Application inorder to make my program formless, but I
>>wanted to use the TTimer component in my app and I cannot figure out how to
>>create an object at runtime without a form to pass as the parent. The help
>>files suggest that 'Self' be used as the parent (Timer :=
>>TTimer.Create(Self)), but I get an error saying that it doesn't know what
>>self is and the docs don't give a reference to a unit that defines Self.

>>Once I gave up on going formless I tried to make a form and hide it in the
>>form's OnCreate Event, but this doesn't work. I don't know why, I don't get
>>an error, it just doesn't work. But I know this form can be hiden because if
>>I put a button on this form and have the button's OnClick Event Hide the form
>>everything works fine.

>>So can anyone tell me how to do 1 of these

..

Quote
>>2. Hide my main form for the whole program execution.
>  don't declare a main form-- undeclare the main form if your project
>  started out with one.  Design a form with a timer on it as non-auto-
>  create.  In your dpr file, create the form by hand, with the
>  visible:= false property.  Create it with the timer disabled.
>  When you are done with your setup, enable the timer.  The form does
>  not need to be visible to do so.

William, have you tried creating this?  I have tried to this in a few
different ways, and Delphi always does the same thing - the first form
created is the primary form, and it will not be created invisible, even
it Visible := false in the object inspector or in the FormCreate
procedure.  I may have missed something, though.  If you have some
working code, could you post it?  Thank you.

Marcus.

Re:Help-non-visual components without forms OR how to hide your main form


Quote
Marc Chapman <mchap...@mstarlabs.com> wrote:
>ridge...@u.washington.edu (Thomas Ridgeway) wrote:
>>bad...@crow.delta-eng.com (William Holtz) wrote:
>>>So can anyone tell me how to do 1 of these
>..
>>>2. Hide my main form for the whole program execution.
>>  don't declare a main form-- undeclare the main form if your project
>>  started out with one.  Design a form with a timer on it as non-auto-
>>  create.  In your dpr file, create the form by hand, with the
>>  visible:= false property.  Create it with the timer disabled.
>>  When you are done with your setup, enable the timer.  The form does
>>  not need to be visible to do so.
>William, have you tried creating this?  I have tried to this in a few
>different ways, and Delphi always does the same thing - the first form
>created is the primary form, and it will not be created invisible, even
>it Visible := false in the object inspector or in the FormCreate
>procedure.  I may have missed something, though.  If you have some
>working code, could you post it?  Thank you.

  Go to the project options page; move all forms from the auto-create
forms window to the available forms window --- your main form entry
will go blank and the dpr file will no longer have an Application.run
statement [there are other ways to accomplish this same result].  You
will be on your own to create and destroy the forms, and to arrange to
call any methods of objects on those forms which you want to do
something.  You will also have a run-silent run-deep application,
which is what you are looking for.

Tom

Re:Help-non-visual components without forms OR how to hide your main form


In article <48av7g$...@news.halcyon.com>, mchap...@mstarlabs.com says...

Quote
>William, have you tried creating this?  I have tried to this in a few
>different ways, and Delphi always does the same thing - the first form
>created is the primary form, and it will not be created invisible, even
>it Visible := false in the object inspector or in the FormCreate
>procedure.  I may have missed something, though.  If you have some
>working code, could you post it?  Thank you.

>Marcus.

I haven't had any luck with it either.

---
William

bad...@crow.delta-eng.com

Other Threads