sfern
asked on
Stop Program Popup Errors and exceptions
Hi all,
I'm writing a program that does everything on timer basis.
And the program will be sitting on the windows tray, unattended.
When there is an error, i get a popup message, instead i want it to write the error on a memo.
I've tried:
Try...
execpt... etc...
and also the windows critical error stopping function, but i still get a popup.
How can i stop this? And i mean with any exception or error?
Thanks
SFern.
I'm writing a program that does everything on timer basis.
And the program will be sitting on the windows tray, unattended.
When there is an error, i get a popup message, instead i want it to write the error on a memo.
I've tried:
Try...
execpt... etc...
and also the windows critical error stopping function, but i still get a popup.
How can i stop this? And i mean with any exception or error?
Thanks
SFern.
try
// ..........
except
on e : exception do
Memo1.Add(e.Message);
end;
You will get a popup only when run your application under Delphi IDE. When you run it by the .exe file, you will don't get a popup exception....
// ..........
except
on e : exception do
Memo1.Add(e.Message);
end;
You will get a popup only when run your application under Delphi IDE. When you run it by the .exe file, you will don't get a popup exception....
i didn't mean to say - "override" the Applications.OnExeception, i meant to say
Assign your own method to the Applications.OnException
This works great,, cause it prevents you from having to place try ... except blocks everywhere in you program,
its global and will catch them all....
Shane
Assign your own method to the Applications.OnException
This works great,, cause it prevents you from having to place try ... except blocks everywhere in you program,
its global and will catch them all....
Shane
ASKER
If trying the first example but i get:
Undeclared identifier OnExeception :(
What i'm i doing wrong, i'm i putting the Protected in the wrong place?
Thanks
Undeclared identifier OnExeception :(
What i'm i doing wrong, i'm i putting the Protected in the wrong place?
Thanks
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;
type
TForm1 = class(TForm)
Memo1: TMemo;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
protected
procedure DisplayExceptions(Sender: TObject; E: Exception);
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.DisplayExceptions(S ender: TObject; E: Exception);
begin
Memo1.Lines.Add(E.Message) ;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Application.OnException:= DisplayExceptions;
end;
end.
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;
type
TForm1 = class(TForm)
Memo1: TMemo;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
protected
procedure DisplayExceptions(Sender: TObject; E: Exception);
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.DisplayExceptions(S
begin
Memo1.Lines.Add(E.Message)
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Application.OnException:= DisplayExceptions;
end;
end.
ASKER
I'm getting the same error, does it require an addition in the uses section?
this is how it looks:
.....
private
{ Private declarations }
procedure AddToListView(Value, From: string);
procedure ToggleStatus(const Status: Boolean);
public
{ Public declarations }
protected
procedure DisplayExceptions(Sender: TObject; E: Exception);
......
implementation
{$R *.dfm}
procedure TOBJ_MainForm.DisplayExcep tions(Send er: TObject; E: Exception);
begin
Memo1.Lines.Add(E.Message) ;
end;
.......
procedure TOBJ_MainForm.FormCreate(S ender: TObject);
begin
Application.OnExeception:= DisplayExceptions;
SendingMail:=False; //Set SendingMail to False
Statusbar1.Panels[1].text := ('Disconnected');
If POP.Connected then
POP.Disconnect;
if Win32Platform = VER_PLATFORM_WIN32_NT then
Font.Name := 'MS Shell Dlg 2'
else
Font.Name := 'MS Shell Dlg';
end;
.....
I'm getting 2 errors:
Undeclared identifier OnExeception
and
Not enough actual parameters.
What i'm i doing wrong?
Thanks
this is how it looks:
.....
private
{ Private declarations }
procedure AddToListView(Value, From: string);
procedure ToggleStatus(const Status: Boolean);
public
{ Public declarations }
protected
procedure DisplayExceptions(Sender: TObject; E: Exception);
......
implementation
{$R *.dfm}
procedure TOBJ_MainForm.DisplayExcep
begin
Memo1.Lines.Add(E.Message)
end;
.......
procedure TOBJ_MainForm.FormCreate(S
begin
Application.OnExeception:=
SendingMail:=False; //Set SendingMail to False
Statusbar1.Panels[1].text := ('Disconnected');
If POP.Connected then
POP.Disconnect;
if Win32Platform = VER_PLATFORM_WIN32_NT then
Font.Name := 'MS Shell Dlg 2'
else
Font.Name := 'MS Shell Dlg';
end;
.....
I'm getting 2 errors:
Undeclared identifier OnExeception
and
Not enough actual parameters.
What i'm i doing wrong?
Thanks
hmmm, what version of delphi are you using....
SHane
SHane
Try creating a blank application and try pluggin in my code and see what you get
SHane
SHane
ASKER
OK, thanks, i have to try it a bit later though, from home.
I'll let you know later..thanks :)
I'll let you know later..thanks :)
ASKER
Cannot get it to work, same errors :(
Any ideas?
Thanks
Any ideas?
Thanks
Again, what version of delphi????
Shane
Shane
and did you create a blank application?
Shane
Shane
ASKER
yes :(
I'm using delphi 6 Ent
I'm using delphi 6 Ent
k, open up help, search for TApplication, and look at its events
You should see OnException
Shane
You should see OnException
Shane
Let me know if you find it?
Shane
Shane
ASKER
Ok, i tried again and managed to make it work on a new application but for some reason the
formcreate section gives me those errors
Very strange :(
formcreate section gives me those errors
Very strange :(
hmmm - in your application , or in the new blank application.
Cause i dont get any errors in my Form Create
Shane
Cause i dont get any errors in my Form Create
Shane
you can actually place it anywhere you like - but the higher up the ladder, the more likely you are to miss exceptions - thats why i suggest in the form create. You could also assign it in the form's onActivate
or .... in the project source, but since you will be writing your exceptions to a tmemo, you will want it in the main form.
Shane
or .... in the project source, but since you will be writing your exceptions to a tmemo, you will want it in the main form.
Shane
ASKER
This part gives me the errors, the rest are accepted.
procedure TOBJ_MainForm.FormCreate(S ender: TObject);
begin
Application.OnExeception:= DisplayExceptions; // <---This line !!!
SendingMail:=False; //Set SendingMail to False
Statusbar1.Panels[1].text := ('Disconnected');
If POP.Connected then
POP.Disconnect;
if Win32Platform = VER_PLATFORM_WIN32_NT then
Font.Name := 'MS Shell Dlg 2'
else
Font.Name := 'MS Shell Dlg';
end;
procedure TOBJ_MainForm.FormCreate(S
begin
Application.OnExeception:=
SendingMail:=False; //Set SendingMail to False
Statusbar1.Panels[1].text := ('Disconnected');
If POP.Connected then
POP.Disconnect;
if Win32Platform = VER_PLATFORM_WIN32_NT then
Font.Name := 'MS Shell Dlg 2'
else
Font.Name := 'MS Shell Dlg';
end;
Did you try doing it in a blank project?
Shane
Shane
Never mind, i think i know why
add that line to the form's onActivate event
Shane
add that line to the form's onActivate event
Shane
Not that i think of it, the window handle to Memo is not created yet, therefor you will get a error message, so therefore the lowerst level for you would be form's onactivate event - place it there
Shane
Shane
ASKER
Same error :(
This is REALLY STRANGE
This is REALLY STRANGE
ASKER
Undeclared Identifier??????????
It's declared :(
It's declared :(
OK, paste me here the whole unit from the blank project you created with just the memo on it
Shane
Shane
ASKER
It does'nt know Onexception :(
Strange !!!
Strange !!!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If it does and your still getting errors, then you definetly have a faulty install of delphi - is all i can say
double check your uses clause as well, make sure everything matches up
Shane
double check your uses clause as well, make sure everything matches up
Shane
ASKER
Got it !!!
Spelling mistake, it's now compiling!!!
but i still get a popup message on this line:
if (ChilkatMailMan1.SendEmail (email) = 0) then //on mail error
begin
Memo1.Lines.Add('Error found');
should i take it off?
Spelling mistake, it's now compiling!!!
but i still get a popup message on this line:
if (ChilkatMailMan1.SendEmail
begin
Memo1.Lines.Add('Error found');
should i take it off?
when you compile and run it outside of delphi ide do you get it as well
Shane
Shane
ASKER
I'll check
ASKER
GREAT!!!! It's now working...wow...applicatio n completed :)
I'm giving you the rest of my points that i have left.
Thanks for all your great help :)
I'm giving you the rest of my points that i have left.
Thanks for all your great help :)
ASKER
Did you get your points?
yes, thanks!
Shane
Shane
Write it out to your memo
protected
procedure DisplayExceptions(Sender: TObject; E: Exception);
procedure TForm1.DisplayExceptions(S
begin
Memo1.Lines.Add(E.Message)
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Application.OnExeception:=
end;