Link to home
Start Free TrialLog in
Avatar of andrezzz
andrezzz

asked on

hide my form

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...
ASKER CERTIFIED SOLUTION
Avatar of BdLm
BdLm
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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;
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
procedure TForm1.HideSelf;
begin
  Hide;
  Application.ProcessMessages;
end;
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of andrezzz
andrezzz

ASKER

i put in
procedure TForm1.FormCreate(Sender: TObject);

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

BUT IT DIDN'T WORK :/
you need:
  Hide;
  Application.ProcessMessages;
to be processed ....
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.
-Karamja-,

  Application.Run;
 Application.ShowMainForm:= False;

will be executed after Application is closed ....
Yep my bad, Put it wrong place.

  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  Application.ShowMainForm:= False;
  Application.Run;
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;
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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
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.
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
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%
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;
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).
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.
You can get datamodule:

File > New > Datamodule

Remove form first :
 Project > Remove from project