Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Formless application

Posted on 1998-12-02
8
Medium Priority
?
156 Views
Last Modified: 2010-04-04
I want to create an application that does not have a form.  However,  I want it to make use of the Timer component so that when a certain time is reached it displays a message to the user.  How can this be done ?

I would be grateful for any advice offered regarding this.

John Clarke
0
Comment
Question by:johnclarke
  • 7
8 Comments
 
LVL 3

Accepted Solution

by:
williams2 earned 400 total points
ID: 1348893
Try using this at the Forms OnCreate event:

Application.ShowMainForm:= False;

regards
Williams
0
 

Author Comment

by:johnclarke
ID: 1348894
I tried this in Delphi 1 and unfortunately it does not work.

John
0
 
LVL 3

Expert Comment

by:williams2
ID: 1348895
You are a most Generous guy mr. John Clarke, so I think I'll provide you with an example:

You'll just have to open Delphi, DoubleClick the OnCreate event of Form1, and then cut'n'paste the following lines into unit1:

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ExtCtrls;

type
  TForm1 = class(TForm)
    Timer1: TTimer;
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    Timer: TTimer;
    procedure OnTimer(Sender: TObject);
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.FormCreate(Sender: TObject);
begin
  Timer:= TTimer.Create(Self);
  Timer.OnTimer:= OnTimer;
  Timer.Interval:= 10000;
  Timer.Enabled:= True;
  Application.ShowMainForm:= False;
end;

procedure TForm1.OnTimer(Sender: TObject);
begin
  If MessageDlg('Every ten seconds!, should I close now?',
                mtInformation,
                [mbYes,mbNo],
                0)=id_Yes
  Then Application.Terminate;
end;

end.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Expert Comment

by:williams2
ID: 1348896
You are a most Generous guy mr. John Clarke, so I think I'll provide you with an example:

You'll just have to open Delphi, DoubleClick the OnCreate event of Form1, and then cut'n'paste the following lines into unit1:

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ExtCtrls;

type
  TForm1 = class(TForm)
    Timer1: TTimer;
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    Timer: TTimer;
    procedure OnTimer(Sender: TObject);
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.FormCreate(Sender: TObject);
begin
  Timer:= TTimer.Create(Self);
  Timer.OnTimer:= OnTimer;
  Timer.Interval:= 10000;
  Timer.Enabled:= True;
  Application.ShowMainForm:= False;
end;

procedure TForm1.OnTimer(Sender: TObject);
begin
  If MessageDlg('Every ten seconds!, should I close now?',
                mtInformation,
                [mbYes,mbNo],
                0)=id_Yes
  Then Application.Terminate;
end;

end.
0
 
LVL 3

Expert Comment

by:williams2
ID: 1348897
Hmmm.. some error happened above, eh? ..What is the error saying?
0
 
LVL 3

Expert Comment

by:williams2
ID: 1348898
Hmmm.. some error happened above, eh? ..What is the error saying?
0
 
LVL 3

Expert Comment

by:williams2
ID: 1348899
Hmmm.. some error happened above, eh? ..What is the error saying?
0
 
LVL 3

Expert Comment

by:williams2
ID: 1348900
ok, this is a hack! Try it with the forms OnPaint event, or at least after the window is stopped showing (Not OnShow!)

procedure TForm1.FormPaint(Sender: TObject);
begin
  Hide;
end;
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses
Course of the Month12 days, 19 hours left to enroll

971 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