Solved

hide my form

Posted on 2004-07-30
23
327 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

895 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now