Solved

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

Posted on 2009-07-13
2
221 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 14

Accepted Solution

by:
SteveBay earned 500 total points
ID: 24842570
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
ID: 31602901
Thanks a lot. Easy as falling of a log - as long as you know how to
0

Featured Post

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Suggested Courses
Course of the Month7 days, 22 hours left to enroll

617 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