Board index » cppbuilder » How to hide automated form/exe

How to hide automated form/exe

I have several apps that include OLE Automation. How do I hide the
form/app if it is accessed remotely? I have tried the following code in
the FormCreate event, to no affect; the form is still there...

if (Automation->StartMode == smAutomation)
   {
   UserEdit1->Visible = false;
   }
// UserEdit1 is the main form.

Any hints?

 

Re:How to hide automated form/exe


From the FAQs at
http://www.borland.com/devsupport/bcppbuilder/qna/qnaspage.html:

Question:
How do I hide an application from the user at startup (ie: no window  
and nothing in the taskbar.)

Answer:
In the Application SOURCE (MyProgram.cpp), after the
Application->Initialize(); add the followng code:

ShowWindow( Application->Handle, SW_HIDE );
Application->ShowMainForm = false;

This will cause the application not to show up anywhere except in
a view of the processes, ie: WinNT TaskManager and PView.

Jim

Re:How to hide automated form/exe


This code does indeed hide the app. What I wanted was an app that hides
when invoked from the OLE automation link, but ran and showed as a
regular app when started as a standalone. Using your helpfull hints, the
following code does that! Modify your main (default) form as follows:

void __fastcall TForm1::FormCreate(TObject *Sender)
{
/// other code here
if (Automation->StartMode == smAutomation)
   {
   TForm1->Visible = false;
   ShowWindow(Application->Handle, SW_HIDE);
   Application->ShowMainForm = false;
   }
/// and more code here

Quote
}

Thanks for the help!
Quote
Jim Melsom wrote:
> From the FAQs at
> http://www.borland.com/devsupport/bcppbuilder/qna/qnaspage.html:

> Question:
> How do I hide an application from the user at startup (ie: no window
> and nothing in the taskbar.)

> Answer:
> In the Application SOURCE (MyProgram.cpp), after the
> Application->Initialize(); add the followng code:

> ShowWindow( Application->Handle, SW_HIDE );
> Application->ShowMainForm = false;

> This will cause the application not to show up anywhere except in
> a view of the processes, ie: WinNT TaskManager and PView.

> Jim

Other Threads