Solved

How can I access the events of a component created at run time.

Posted on 2009-07-13
2
213 Views
Last Modified: 2012-05-07
I have created indy idSmtp atb runtime but need to display the status supplied by the onstatus event
0
Comment
Question by:gerhard9121
2 Comments
 
LVL 14

Accepted Solution

by:
SteveBay earned 500 total points
Comment Utility
You will need to subclass it in order to have access to the protected event procedures
It should look something like this:
unit Unit1;
 

interface
 

uses

  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

  Dialogs, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient,

  IdExplicitTLSClientServerBase, IdMessageClient, IdSMTPBase, IdSMTP;
 

type TMySmtp = class(TIdSMTP);
 

type

  TForm1 = class(TForm)

    procedure FormCreate(Sender: TObject);

  private

     MySMTP : TMySmtp;

    procedure MySMTPStatus(ASender: TObject; const AStatus: TIdStatus; const AStatusText: string);

    { Private declarations }

  public
 

    { Public declarations }

  end;
 

var

  Form1: TForm1;
 

implementation
 

{$R *.dfm}
 

procedure TForm1.FormCreate(Sender: TObject);

begin

     MySMTP := TMySmtp.Create(Self);

     MySMTP.OnStatus := MySMTPStatus;

end;
 

procedure TForm1.MySMTPStatus(ASender: TObject; const AStatus: TIdStatus;  const AStatusText: string);

begin

     // do Status stuff

end;
 

end.

Open in new window

0
 

Author Closing Comment

by:gerhard9121
Comment Utility
Thanks a lot. Easy as falling of a log - as long as you know how to
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

763 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

6 Experts available now in Live!

Get 1:1 Help Now