how to activate program's main from after a time t seconds ?

i have got a database with 2 fields,
Date and Time. I want my program's main form to be hidden untill date and time is equel to those in the database.

My problem is that I cannot dynamically create my mainform when the time occurs.

Any help is appreciated.

Thanks
LVL 1
drnadeemAsked:
Who is Participating?
 
Ten13Connect With a Mentor Commented:
To start your application totally invisible you have to do this:

In your project file (.dpr) add one line of code:
  Application.Initialize; (*already there*)
  Application.CreateForm(TfrmMain, frmMain); (*already there*)
  Application.ShowMainForm:= false; (*add this line*)
  Application.Run; (*already there*)

In you main form "FormCreate" event add this:
procedure TForm1.FormCreate(Sender: TObject);
begin
  ShowWindow(Application.Handle, SW_HIDE);  (*add this line*)
end;

When you want to display your application and mainform (propably with a timer) do this:
procedure TfrmMain.Timer1Timer(Sender: TObject);
begin
  if ConditionsToDisplayApplicationIsOK then begin
    ShowWindow(Application.Handle, SW_SHOW);  (*add this line*)
    Visible:= true;  (*add this line*)
  end;
end;

That's it. No more, no less. Hope it is what you're looking for.

- Martin
0
 
zwarteCommented:
hi drnadeem,

form1.hide
form1.show

tom,
0
 
manjushanCommented:
Hi,
   Put a timmer component. And in the on timmer event check for the date and time of your database. Then u can do the above. form1.hide or Form1.Show.
       All the best.
            Manju.
                             
                       
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
AttarSoftwareCommented:
in Main forms {Private} section :

  procedure WMHIDE( var msg : tMessage ) ; message WM_USER + 1 ;

and then in Implementation section :

procedure tForm1.WMHIDE( var msg : tMessage ) ;
begin
  ShowWindow( Application.Handle, SW_HIDE ) ;
  ShowWindow( Handle, SW_HIDE ) ;
end ;

and in the OnShow event of your main form :

procedure tForm1.FormShow( sender : tObject ) ;
begin
  PostMessage( handle, WM_USER + 1, 0, 0 ) ;
end ;

and then :

procedure TForm1.Timer1Timer( sender : tObject ) ;
begin
  if( TimesMatchFunction ) then
  begin
    ShowWindow( Application.Handle, SW_SHOW ) ;
    ShowWindow( Handle, SW_SHOW ) ;
  end ;
end ;

Obviously, you'll have to write the TimesMatchFunction function ;O)

Good luck

Tim.
 
0
 
AttarSoftwareCommented:
Oh yeah, and you'll have to add Timer1 to the main form too :)

(as Manju said -- hee hee, that comment came in whilst I was typing ;O) )

Tim.
0
 
zwarteCommented:
functions to use
function date: tdatetime
function time: tdatetime
timetostr(tdatetime):string
datetostr(tdatetime):string
comparestr(str1,str2 : string):integer

apparently I missed part of the question due to a lack of attention, but its been a boring day so I just thought I'd spare you some lookup work :-)

Tom,
0
All Courses

From novice to tech pro — start learning today.