Solved

hide my form

Posted on 2004-07-30
23
323 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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 The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

743 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

11 Experts available now in Live!

Get 1:1 Help Now