Solved

Formless application

Posted on 1998-12-02
8
146 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 100 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
 
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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

747 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