Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

assigning an exception handler in a library

Posted on 2014-08-05
2
Medium Priority
?
208 Views
Last Modified: 2014-08-07
I have written an exception handler that needs to be used by multiple programs, so I put it in a bpl.  However, when I try to assign the exception handler in the program like this:
Application.OnException := MyLibrary.ExceptHandler;

Open in new window

I get "Incompatible types: 'method pointer and regular procedure'". I understand that method pointers and regular procedures are different, but I don't know how to declare the exception handler in the library so it's a method pointer. I tried putting it in a class in the library, but this didn't make a difference.
Thanks in advance for your help.
0
Comment
Question by:EricTaylor
2 Comments
 
LVL 28

Accepted Solution

by:
Sinisa Vuk earned 2000 total points
ID: 40242199
try define separate class:
type
  TAppExceptionEventHandler = class
    procedure OnAppException(Sender: TObject; E: Exception);
  end;

var
  AppExceptionEventHandler: TAppExceptionEventHandler;
.... //implementation

procedure TAppExceptionEventHandler.OnAppException(Sender: TObject; E: Exception);
begin
//do stuff here
end;

Open in new window


... and use it like:
Application.OnException := AppExceptionEventHandler.OnAppException;

Open in new window

0
 

Author Closing Comment

by:EricTaylor
ID: 40246692
Thanks. That did it. (I tried creating the c lass previously, but forgot to create the var part so I could access it. Your example helped.)
0

Featured Post

Technology Partners: 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

We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
No other job is as rewarding and demanding as building an iPhone app is. It is not really in the hands of the developer for the success of an iPhone app. Many factors operate jointly for every iOS application's success in the market.
Six Sigma Control Plans
Progress

578 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