Solved

hide my form

Posted on 2004-07-30
23
331 Views
Last Modified: 2010-04-05
i have little programm with form, on form I have TIMER, IdHTTP, IdIOHandlerSocket1.

ny program starts on FormCreate and after it all work is on every second in timer.

but now i must hide my form. the form must not be shown. HOW I CAN CREATE THIS. PLEASE HELP. THX...
0
Comment
Question by:andrezzz
  • 6
  • 4
  • 3
  • +5
23 Comments
 
LVL 8

Accepted Solution

by:
BdLm earned 23 total points
ID: 11678320
move it to place where nobody will see it:


procedure  TForm.Hide
begin
      Form.Left:=9999;
      Form.Top:=9999;
end;  
0
 
LVL 2

Assisted Solution

by:-Karamja-
-Karamja- earned 23 total points
ID: 11678329
Application.ShowMainForm:= False;

Put it on form create
0
 
LVL 8

Expert Comment

by:BdLm
ID: 11678357
procedure  TForm.Hide
begin
      UnhideLeft := Form.left;
      UnhideTop:= Form.Top;

      Form.Left:=9999;
      Form.Top:=9999;
end;  


procedure TForm.Unhide;
begin
      Form.Left:=UnhideLeft;
      Form.Top:=UnhideTop;

end;
0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
LVL 12

Assisted Solution

by:esoftbg
esoftbg earned 23 total points
ID: 11678544
procedure TForm1.HideSelf;
begin
  Form1.Hide;
  Application.ProcessMessages;
end;
0
 
LVL 12

Expert Comment

by:esoftbg
ID: 11678569
procedure TForm1.HideSelf;
begin
  Hide;
  Application.ProcessMessages;
end;
0
 
LVL 4

Assisted Solution

by:tobjectpascal
tobjectpascal earned 23 total points
ID: 11678599
procedure TForm1.Button1Click(Sender: TObject);
begin
  Form1.Visible:=False;
end;

//Form1.Visible:=True; to bring it back (i know it's rocket science but what ya going to do :P )
0
 

Author Comment

by:andrezzz
ID: 11678696
i put in
procedure TForm1.FormCreate(Sender: TObject);

Form1.Visible:=False;
and
Application.ShowMainForm:= False;

BUT IT DIDN'T WORK :/
0
 
LVL 12

Expert Comment

by:esoftbg
ID: 11678738
you need:
  Hide;
  Application.ProcessMessages;
to be processed ....
0
 
LVL 2

Expert Comment

by:-Karamja-
ID: 11678759
Application.ShowMainForm:= False;
Should work. if not put it on the project file not the unit

program Project1;

uses
  Forms,
  Unit1 in 'Unit1.pas' {Form1};

{$R *.res}

begin
  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  Application.Run;
  Application.ShowMainForm:= False;
end.
0
 
LVL 12

Expert Comment

by:esoftbg
ID: 11678792
-Karamja-,

  Application.Run;
 Application.ShowMainForm:= False;

will be executed after Application is closed ....
0
 
LVL 2

Expert Comment

by:-Karamja-
ID: 11678830
Yep my bad, Put it wrong place.

  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  Application.ShowMainForm:= False;
  Application.Run;
0
 
LVL 12

Expert Comment

by:esoftbg
ID: 11678878
type
  TForm1 = class(TForm)
    //.........
    private   { Private declarations }
      ICount:   Integer;
    public    { Public declarations }
  end;


procedure TForm1.FormCreate(Sender: TObject);
begin
  ICount := 0;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
  Inc(ICount);
  if (ICount=1) then
  begin
    Hide;
    Application.ProcessMessages;
  end;
end;
0
 
LVL 2

Assisted Solution

by:Mrkaras
Mrkaras earned 23 total points
ID: 11687230
i think the problem you are having is that if you hide the form on form create it is showen imediatly after, ie when onCreate finishes. a method that works although not instantly and possably not the best way is to add a 1 ms timer with the code:
form1.Hide;
timer1.Destroy;
to hide your form after create and the you have no need for the timer so it can be distroyed.
0
 
LVL 12

Expert Comment

by:esoftbg
ID: 11688027
Mrkaras,
I think You do not understand the question:

andrezzz have written:
> .... on form I have TIMER, IdHTTP, IdIOHandlerSocket1.
> my program starts on FormCreate and after it all work is on every second in timer.

So, actually the TIMER is used in the programm not about to Hide the Form, but for it's general purpose ....
This way the TIMER may be not be destroyed  ;-))

emil
0
 
LVL 2

Expert Comment

by:php4delphi
ID: 11688138
program Project1;

uses
  Windows,
  Forms,
  Unit1 in 'Unit1.pas' {Form1};

{$R *.res}

begin
  Application.Initialize;
  Application.ShowMainForm := false;
  Application.CreateForm(TForm1, Form1);
  ShowWindow(Application.Handle, SW_HIDE);
  Application.Run;
end.
0
 

Author Comment

by:andrezzz
ID: 11694154
if i use

  Application.Initialize;
  Application.ShowMainForm := false;
  Application.CreateForm(TForm1, Form1);
  ShowWindow(Application.Handle, SW_HIDE);
  Application.Run;

then my programm windows is on desctop but in toolbar where i switch my windowses the windows of my programm is hiden. i need to hide my programm windows too
0
 

Author Comment

by:andrezzz
ID: 11694247
I use

  Application.Initialize;
  Application.ShowMainForm := false;
  Application.CreateForm(TForm1, Form1);
  ShowWindow(Application.Handle, SW_HIDE);
  ShowWindow(Application.MainForm.Handle, SW_HIDE);
  Application.Run;

and it work BUT IT HAVE SOME SPLASH. I CAN SEE MY WONDOWS IN A VERY LITTLE TIME. HOW I CAN HIDE IT 100%
0
 
LVL 2

Expert Comment

by:-Karamja-
ID: 11694274
Application.Initialize;
  Application.ShowMainForm := false;
  Application.CreateForm(TForm1, Form1);
  Application.ShowMainForm:= False;
  ShowWindow(Application.Handle, SW_HIDE);
  ShowWindow(Application.MainForm.Handle, SW_HIDE);
  Application.Run;
0
 
LVL 2

Expert Comment

by:Mrkaras
ID: 11742239
would it help to set the position of the window to someware off the screen (such as setting left to -1000000) as well as hiding your application as yoy have got working? if you set the position with the object inspector you will never see your form but you may still have the taskbar flash up quickly.

also in my previous comment i ment a seperate timer, not the one already on your form (it looks like you got some better answers after my other comment anyway).
0
 
LVL 1

Expert Comment

by:TiborKi
ID: 13028030
Use DataModule, not form, if you have just non-visual components.

unit Unit1;

interface

uses
  SysUtils, Classes, Forms;

type
  TDataModule1 = class(TDataModule)
// Your Components
    procedure DataModuleCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  DataModule1: TDataModule1;

implementation

{$R *.dfm}

//Your implementetion

procedure TDataModule1.DataModuleCreate(Sender: TObject);
begin
While True Do
if Application.Terminated then Break
else
Application.HandleMessage;
end;

end.
0
 
LVL 1

Expert Comment

by:TiborKi
ID: 13028060
You can get datamodule:

File > New > Datamodule

Remove form first :
 Project > Remove from project
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
FMX enumerated colours 2 100
Press three keys together and trigger a function 3 57
Dynamically Created Query 3 55
Delphi: making a BW image transparent 10 38
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

778 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question